Is there anyone who can help me?I post it before.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • viorel

    Is there anyone who can help me?I post it before.

    Greeting All!

    Is some one who can help me?

    The problem is when I use a func(_GetDNSSer vers) from a native dll which is
    responsible in returning DNS servers address.

    public class DNSQuery
    {
    [DllImport("GetD NSDLL.dll")]
    public static extern IntPtr _GetDNSServers( );
    public void PerformSomeActi ons()
    {
    . . .
    byte[]buffer=new byte[1000];
    System.Runtime. InteropServices .Marshal.Copy(_ GetDNSServers() , buffer,0,
    1000);
    . . .
    string strt=System.Tex t.Encoding.ASCI I.GetString(buf fer,0,1000);
    strt= strt.Split(';')[0];
    this.DNSHost=Sy stem.Net.Dns.Ge tHostByAddress( strt).AddressLi st[0];
    IPEndPoint ipendp=new IPEndPoint(DNSH ost, 53);
    sock.Connect(ip endp);
    // ??????????????? ?An Error will happened!!!
    sock = new
    Socket(AddressF amily.InterNetw ork,socketType. Stream,Protocol Type.Tcp);
    //??????????????? ??An Error has been!!!
    . . .
    }
    }
    Message of exception is
    An unhandled exception of type 'System.Executi onEngineExcepti on' occurred in
    system.dll

    When I do not use _GetDNSServers( ),I use a known server address, connection
    is done.

    _GetDNSServers( ) returns char * (a pointer to an array of chars(1 byte
    perchar)) which contains all DNS servers address from that domain

    How to avoid the problem?

    Thks!







  • Eric Gunnerson [MS]

    #2
    Re: Is there anyone who can help me?I post it before.

    dotnet.framewor k.interop is probably a better place to ask this. You'll want
    to add in the C prototype of the function you're trying to call.

    --
    Eric Gunnerson

    Visit the C# product team at http://www.csharp.net
    Eric's blog is at http://blogs.gotdotnet.com/ericgu/

    This posting is provided "AS IS" with no warranties, and confers no rights.
    "viorel" <vmaleavschi@ho tmail.com> wrote in message
    news:OgsfQFngDH A.1088@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Greeting All!
    >
    > Is some one who can help me?
    >
    > The problem is when I use a func(_GetDNSSer vers) from a native dll which[/color]
    is[color=blue]
    > responsible in returning DNS servers address.
    >
    > public class DNSQuery
    > {
    > [DllImport("GetD NSDLL.dll")]
    > public static extern IntPtr _GetDNSServers( );
    > public void PerformSomeActi ons()
    > {
    > . . .
    > byte[]buffer=new byte[1000];
    > System.Runtime. InteropServices .Marshal.Copy(_ GetDNSServers() ,[/color]
    buffer,0,[color=blue]
    > 1000);
    > . . .
    > string strt=System.Tex t.Encoding.ASCI I.GetString(buf fer,0,1000);
    > strt= strt.Split(';')[0];
    > this.DNSHost=Sy stem.Net.Dns.Ge tHostByAddress( strt).AddressLi st[0];
    > IPEndPoint ipendp=new IPEndPoint(DNSH ost, 53);
    > sock.Connect(ip endp);
    > // ??????????????? ?An Error will happened!!!
    > sock = new
    > Socket(AddressF amily.InterNetw ork,socketType. Stream,Protocol Type.Tcp);
    > //??????????????? ??An Error has been!!!
    > . . .
    > }
    > }
    > Message of exception is
    > An unhandled exception of type 'System.Executi onEngineExcepti on' occurred[/color]
    in[color=blue]
    > system.dll
    >
    > When I do not use _GetDNSServers( ),I use a known server address,[/color]
    connection[color=blue]
    > is done.
    >
    > _GetDNSServers( ) returns char * (a pointer to an array of chars(1 byte
    > perchar)) which contains all DNS servers address from that domain
    >
    > How to avoid the problem?
    >
    > Thks!
    >
    >
    >
    >
    >
    >
    >[/color]


    Comment

    • Eric Gunnerson [MS]

      #3
      Re: Is there anyone who can help me?I post it before.

      dotnet.framewor k.interop is probably a better place to ask this. You'll want
      to add in the C prototype of the function you're trying to call.

      --
      Eric Gunnerson

      Visit the C# product team at http://www.csharp.net
      Eric's blog is at http://blogs.gotdotnet.com/ericgu/

      This posting is provided "AS IS" with no warranties, and confers no rights.
      "viorel" <vmaleavschi@ho tmail.com> wrote in message
      news:OgsfQFngDH A.1088@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Greeting All!
      >
      > Is some one who can help me?
      >
      > The problem is when I use a func(_GetDNSSer vers) from a native dll which[/color]
      is[color=blue]
      > responsible in returning DNS servers address.
      >
      > public class DNSQuery
      > {
      > [DllImport("GetD NSDLL.dll")]
      > public static extern IntPtr _GetDNSServers( );
      > public void PerformSomeActi ons()
      > {
      > . . .
      > byte[]buffer=new byte[1000];
      > System.Runtime. InteropServices .Marshal.Copy(_ GetDNSServers() ,[/color]
      buffer,0,[color=blue]
      > 1000);
      > . . .
      > string strt=System.Tex t.Encoding.ASCI I.GetString(buf fer,0,1000);
      > strt= strt.Split(';')[0];
      > this.DNSHost=Sy stem.Net.Dns.Ge tHostByAddress( strt).AddressLi st[0];
      > IPEndPoint ipendp=new IPEndPoint(DNSH ost, 53);
      > sock.Connect(ip endp);
      > // ??????????????? ?An Error will happened!!!
      > sock = new
      > Socket(AddressF amily.InterNetw ork,socketType. Stream,Protocol Type.Tcp);
      > //??????????????? ??An Error has been!!!
      > . . .
      > }
      > }
      > Message of exception is
      > An unhandled exception of type 'System.Executi onEngineExcepti on' occurred[/color]
      in[color=blue]
      > system.dll
      >
      > When I do not use _GetDNSServers( ),I use a known server address,[/color]
      connection[color=blue]
      > is done.
      >
      > _GetDNSServers( ) returns char * (a pointer to an array of chars(1 byte
      > perchar)) which contains all DNS servers address from that domain
      >
      > How to avoid the problem?
      >
      > Thks!
      >
      >
      >
      >
      >
      >
      >[/color]


      Comment

      Working...