473,320 Members | 2,054 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,320 software developers and data experts.

DLLImport and "First time exception" ?

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 ?
Nov 17 '05 #1
10 4283

"Fabien Penso" <fa*********@gmailNOSPAM.com> wrote in message
news:uF**************@TK2MSFTNGP15.phx.gbl...
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.
Nov 17 '05 #2
Willy Denoyette [MVP] wrote:

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.

Sure. The .dll I use is : http://penso.info/tmp/sipXtapid.dll (the
release version at http://penso.info/tmp/sipXtapi.dll works fine, it's
strange...).

The C# code is as following :

http://lasalas.net/paste/535
Nov 17 '05 #3

"Fabien Penso" <fa*********@gmailNOSPAM.com> wrote in message
news:ug**************@TK2MSFTNGP15.phx.gbl...
Willy Denoyette [MVP] wrote:

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.

Sure. The .dll I use is : http://penso.info/tmp/sipXtapid.dll (the
release version at http://penso.info/tmp/sipXtapi.dll works fine, it's
strange...).

The C# code is as following :

http://lasalas.net/paste/535


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

Willy.
Nov 17 '05 #4
>Sure. The .dll I use is : http://penso.info/tmp/sipXtapid.dll (the
release version at http://penso.info/tmp/sipXtapi.dll works fine, it's
strange...).

The C# code is as following :

http://lasalas.net/paste/535

The functions seem to use the cdecl calling convention. Try specifying
that in the DllImport attribute.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #5
Mattias Sjögren wrote:
Sure. The .dll I use is : http://penso.info/tmp/sipXtapid.dll (the
release version at http://penso.info/tmp/sipXtapi.dll works fine, it's
strange...).

The C# code is as following :

http://lasalas.net/paste/535


The functions seem to use the cdecl calling convention. Try specifying
that in the DllImport attribute.


I just tried

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

but it makes no difference, still that first chance exception... :(
Nov 17 '05 #6
Willy Denoyette [MVP] wrote:
Sure. The .dll I use is : http://penso.info/tmp/sipXtapid.dll (the
release version at http://penso.info/tmp/sipXtapi.dll works fine, it's
strange...).

The C# code is as following :

http://lasalas.net/paste/535

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.
Nov 17 '05 #7

"Fabien Penso" <fa*********@gmailNOSPAM.com> wrote in message
news:eb**************@TK2MSFTNGP14.phx.gbl...
Mattias Sjögren wrote:
Sure. The .dll I use is : http://penso.info/tmp/sipXtapid.dll (the
release version at http://penso.info/tmp/sipXtapi.dll works fine, it's
strange...).

The C# code is as following :

http://lasalas.net/paste/535


The functions seem to use the cdecl calling convention. Try specifying
that in the DllImport attribute.


I just tried

[DllImport("sipXtapid.dll",CallingConvention=Callin gConvention.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.

Nov 17 '05 #8

"Fabien Penso" <fa*********@gmailNOSPAM.com> wrote in message
news:uT**************@TK2MSFTNGP14.phx.gbl...
Willy Denoyette [MVP] wrote:
Sure. The .dll I use is : http://penso.info/tmp/sipXtapid.dll (the
release version at http://penso.info/tmp/sipXtapi.dll works fine, it's
strange...).

The C# code is as following :

http://lasalas.net/paste/535

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.


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.
Nov 17 '05 #9
Willy Denoyette [MVP] wrote:
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.
Nov 17 '05 #10
I don't know about Error. But u may find some tip from here

Regards,
Divyang Mithaiwala
Jun 30 '06 #11

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

Similar topics

2
by: Chris Herring | last post by:
Hi there: Well, let me start off by saying that I am a Visual Studio drag and drop weenie, not a real programmer. So I tend to get confused when things do not look like the instructions said they...
22
by: Qopit | last post by:
Hi there, I'm pretty new to Python and am trying to figure out how to get "will this code compile?"-like code checking. To me this is a pretty basic language/environment requirement, especially...
2
by: rollasoc | last post by:
Hi, When I load my application I get the the above first chance exception. Stepping through my code it appears to be on the last line of the these two lines Process current =...
32
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open...
6
by: Chris Newcombe | last post by:
Please could someone on the VC++ 7.0 compiler team (note; not 7.1) tell me if this code is handled 'correctly' (i.e. as the original poster suggests) in all cases? ...
5
by: comp.lang.php | last post by:
$orderBy = 's.app_date desc, s.last_name asc, s.first_name asc, s.mi asc'; if ($_REQUEST) { $ascArray = array('asc' => 'desc', 'desc' => 'asc'); // ARRAY OF ALL ORDERING POSSIBILITIES $junk =...
3
by: Dan | last post by:
Hi all! When I throw my custom Exception class the first time in my code, the compiler takes a lot of time for find the following catch EX: try Throw New MyCustomException("test")
2
by: Abubakar | last post by:
Hi all, I'm writing an app in vc++ 2k5 (all native/unmanaged). This application does a lot of multithreading and socket programming. Its been months since I'm developing this application, at...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.