473,804 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DllImport and debug ...

Hi.

I imported a .dll in my C# code and call a C function that takes a
struct of pointers of functions as callback functions. It seems to work
fine (the callbacks function wrote in my C# code are called) for this
part, but then crashes.

When it crashes Visual offers me to use a debugger, but the current
instance of visual can't be selected (only "new instance of visual C++")
and if I choose "new instance" it says another debugger is already
attached to it.

Anyone knows how to fix that ?

I have a very simple question also, how can I enter the .dll code to put
breakpoints while running the C# compiled code ?
Nov 17 '05 #1
2 5119
>I imported a .dll in my C# code and call a C function that takes a
struct of pointers of functions as callback functions. It seems to work
fine (the callbacks function wrote in my C# code are called) for this
part, but then crashes.
Do you hold references to the delegates you pass to the DLL to ensure
that they don't get garbage collected?

When it crashes Visual offers me to use a debugger, but the current
instance of visual can't be selected (only "new instance of visual C++")
and if I choose "new instance" it says another debugger is already
attached to it.

Anyone knows how to fix that ?


See if it makes a difference if you enable unmanaged debugging in the
project properties.

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 #2
Mattias Sjögren wrote:
I imported a .dll in my C# code and call a C function that takes a
struct of pointers of functions as callback functions. It seems to work
fine (the callbacks function wrote in my C# code are called) for this
part, but then crashes.

Do you hold references to the delegates you pass to the DLL to ensure
that they don't get garbage collected?


Yes I do, I now got to see where the error is, thanks to your reply !
Now I need to fix the error :)
See if it makes a difference if you enable unmanaged debugging in the
project properties.


Fixed it, thanks.
Nov 17 '05 #3

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

Similar topics

15
4469
by: Jim | last post by:
I am extremely frustrated. I am building c# application for a call center and am using a third party API to access some hardware. When develop and test my class using the windows console the application runs flawlessly, but once I call the class from inside a c# windows application the program freezes, crashes etc... there must be a way to make this work inside a windows app as it run great as a command line app.
6
5912
by: Tim Mulholland | last post by:
Whats the correct C# datatype (or marshalling function or something) to use when you're importing a function that has a signature similar to char* FuncA(char c) ? Assuming you know that both the parameter for the function and the return value are c-style strings?
10
4317
by: Fabien Penso | last post by:
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
3
3462
by: Mark Jerde | last post by:
I'm sill learning VS .NET 2003, not an expert yet. I'm calling an unmanaged C++ DLL from C# using . When the whole project is done I will be calling a total of 5 C++ DLLs from C#. All the DLLs have the same signature, and I never have to call more than one DLL in the same program. (The DLLs parse and validate 5 different binary formats.) Originally I was expecting to have 5 different C# programs as the constants are different for each...
2
10483
by: Brian Anderson | last post by:
Hello, is it possible to use DllImport to call a DLL in ASP.NET ? Or is it necessarry that my DLL has to be copied into \System32 ? My DLL is a native C++ 7.1 DLL (not managed, no COM, no regsvr32) and uses Assembler to make some math in SSE. The result is given out as an Int. Using a C# console app (code below) it work fine & fast.
1
7300
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error: Creating library Release/fnimqcmd.lib and object Release/fnimqcmd.exp CoIMQCmd.obj : error LNK2001: unresolved external symbol
2
6159
by: =?Utf-8?B?U0FM?= | last post by:
Hello, I am getting the following error: "An attribute argument must be a constant expression, typeof expression or array creation expression" with this line of code on my GetDLLName() that gets the DllName parameter for the DllImport:
9
6489
by: belion | last post by:
Hi, I am facing a strange problem ... a collegue of mine made two projects. The first one is an unmanaged C++ dll , and the other is a C# managed project that uses the previous dll. Both of them are working on his machine, but not in mine. When I run the C# project, I always get a DllNotFoundException, even it the path to the dll is well set (I have checked it). I have also tried to copy the dll to C: \WINDOWS\system32 , but the same...
0
1712
by: Nelson R. | last post by:
Greetings, I've already posted this message on aspnet.security group (think its related to security issues), but since didn't get any response, I post it here. -- I have a problem, and been around it for some days without finding a solution. I have an aspnet 1.1 application that works perfectly on Windows XP, Windows
1
8479
by: Larry | last post by:
I have an asp.net application (C#) that calls a web service that uses several c++ dlls which are loaded with DllImport. I put these dlls in a sub-directory off of the bin directory. For example, lets say the web service dlls reside in c:\<myservice path>. The imported dlls are in c:\<myservice path>\importeddlls. Therefore, the DllIImport declaration looks like this: This is working fine for production. But when I try to debug, it...
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.