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!
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!
Comment