DLLImport and "First time exception" ?

  • Thread starter Thread starter Fabien Penso
  • Start date Start date
F

Fabien Penso

Hi.

I am trying to use the sipX stack from http://www.sipfoundry.org/ into a
c# project. In release mode it works fine, but in Debug mode when I call
the dll imported function I get a :

First-chance exception at 0x001a73c2 in Essai sipx.exe: 0xC0000005:
Access violation reading location 0x001a73c2.

Can someone point me to something about this error ? I can't find a way
to find what to do in such case. If I don't call the dll imported
functions it's ok.

Any idea ?
 
Fabien Penso said:
Hi.

I am trying to use the sipX stack from http://www.sipfoundry.org/ into a
c# project. In release mode it works fine, but in Debug mode when I call
the dll imported function I get a :

First-chance exception at 0x001a73c2 in Essai sipx.exe: 0xC0000005: Access
violation reading location 0x001a73c2.

Can someone point me to something about this error ? I can't find a way to
find what to do in such case. If I don't call the dll imported functions
it's ok.

Any idea ?

No, you should post at least the function declarations (DllImport and the C
function declaration) the and the the code part that call's it.

Willy.
 
Willy said:
The C# code looks ok, time to start the debugger and step through the
sipxInitialize function.

Yeah I would love to do so, but breakpoints doesn't stop anything, and
as you see in my code I put a catch _all_ exceptions and it makes no
differences.
 
Mattias said:
The functions seem to use the cdecl calling convention. Try specifying
that in the DllImport attribute.

I just tried

[DllImport("sipXtapid.dll",CallingConvention=CallingConvention.Cdecl)]

but it makes no difference, still that first chance exception... :(
 
Fabien Penso said:
Mattias said:
The functions seem to use the cdecl calling convention. Try specifying
that in the DllImport attribute.

I just tried

[DllImport("sipXtapid.dll",CallingConvention=CallingConvention.Cdecl)]

but it makes no difference, still that first chance exception... :(

Sure you have to match the calling convention, and set Cdecl when you
function expects Cdecl, but this can never be the cause of the problem.

Willy.
 
Fabien Penso said:
Yeah I would love to do so, but breakpoints doesn't stop anything, and as
you see in my code I put a catch _all_ exceptions and it makes no
differences.

You have to enable native code debugging when running in VS, or simply try
to call the function (the debug version) from a C++ program.


Willy.
 
Willy said:
You have to enable native code debugging when running in VS, or simply try
to call the function (the debug version) from a C++ program.

Debug mode for unmanaged code _is_ enabled... :( I guess I need to do a
little C++ then to call it from C++ instead of C#. I got the feeling
I'll get no errors.
 
Back
Top