V
viorel
Greeting All!
Is some one who can help me?
The problem is when I use a func(_GetDNSServers) from a native dll which is
responsible in returning DNS servers address.
public class DNSQuery
{
[DllImport("GetDNSDLL.dll")]
public static extern IntPtr _GetDNSServers();
public void PerformSomeActions()
{
. . .
byte[]buffer=new byte[1000];
System.Runtime.InteropServices.Marshal.Copy(_GetDNSServers(), buffer,0,
1000);
. . .
string strt=System.Text.Encoding.ASCII.GetString(buffer,0,1000);
strt= strt.Split(';')[0];
this.DNSHost=System.Net.Dns.GetHostByAddress(strt).AddressList[0];
IPEndPoint ipendp=new IPEndPoint(DNSHost, 53);
sock.Connect(ipendp);
// ????????????????An Error will happened!!!
sock = new
Socket(AddressFamily.InterNetwork,socketType.Stream,ProtocolType.Tcp);
//?????????????????An Error has been!!!
. . .
}
}
Message of exception is
An unhandled exception of type 'System.ExecutionEngineException' 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(_GetDNSServers) from a native dll which is
responsible in returning DNS servers address.
public class DNSQuery
{
[DllImport("GetDNSDLL.dll")]
public static extern IntPtr _GetDNSServers();
public void PerformSomeActions()
{
. . .
byte[]buffer=new byte[1000];
System.Runtime.InteropServices.Marshal.Copy(_GetDNSServers(), buffer,0,
1000);
. . .
string strt=System.Text.Encoding.ASCII.GetString(buffer,0,1000);
strt= strt.Split(';')[0];
this.DNSHost=System.Net.Dns.GetHostByAddress(strt).AddressList[0];
IPEndPoint ipendp=new IPEndPoint(DNSHost, 53);
sock.Connect(ipendp);
// ????????????????An Error will happened!!!
sock = new
Socket(AddressFamily.InterNetwork,socketType.Stream,ProtocolType.Tcp);
//?????????????????An Error has been!!!
. . .
}
}
Message of exception is
An unhandled exception of type 'System.ExecutionEngineException' 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!