call a unmanaged dll in ASP.NET app

G

Guest

Hi,
I'm developing an ASP.NET app. In codebehind .cs file i need call an
unmanaged C++ dll.I copied the dll into the bin directory.
the header file of the dll contains the definition as

extern "C" __declspec (dllexport) void FuelEfficiency(COleDateTime
m_dtFuelEffTo,COleDateTime m_dtFuelEffFrom,CString gSimID,char *itemp);

where itemp is out parameter
Declaration of function in C# is:

[DllImport ("VMMYDLL.dll")]
public static extern void FuelEfficiency(DateTime m_dtFuelEffTo,DateTime
m_dtFuelEffFrom,string gSimID,[In,Out] char[] sb );
//calling function on a click event
private void StatSubmit_ServerClick(object sender, System.EventArgs e)
{
DateTime temp = Convert.ToDateTime(TxtFuelToDate.Value);
DateTime temp1 = Convert.ToDateTime(TxtFuelFromDate.Value);
string st = null;
FuelEfficiency(temp,temp1,"919444305923",st);//fn called
Response.Write(st);
}


I get an error :System.Runtime.InteropServices.SEHException: External
component has thrown an exception.
Is the above code correct?
Is there any way to debug unmanaged code in C#?

Thanks in advance
Priya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top