473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

native code problem

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(_GetDN SServers(), 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.Strea m,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!

Nov 15 '05 #1
0 860

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dln | last post by:
Hey all. I'm a bit new to the language and I'm trying to figure out how to have my c# application interact with native code that is exported via a dll. I've run into a problem interfacing with a...
3
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following...
0
by: Reini | last post by:
We are developing an Asp.Net 2.0 application (Web Administration) for the IIS 5.0 to 6.0 and the W2K to W2K3 operating system. The application consists of several layers. One layer is a .Net 2.0...
0
by: Ed | last post by:
Hi, dear all, I want to wrapper the legacy C++ Template Class to be used by the C# code, so I try to wrapper the legacy C++ code into CLI/C++ code first. One problem is how to wrapper C++...
3
etiainen
by: etiainen | last post by:
Hi everyone! I'm in a bit of a problem here: I have to make a maven project for native (jni & C) code. I am using this plugin:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.