call a unmanaged dll in ASP.NET app

Discussion in 'ASP .Net' started by Guest, Oct 28, 2004.

  1. Guest

    Guest 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
     
    Guest, Oct 28, 2004
    #1
    1. Advertisements

  2. Guest

    CJ Taylor Guest

    You might want to look into Marshaling..
     
    CJ Taylor, Oct 28, 2004
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.