Solved

Why Cant I debug an extern C function in my Project?

Posted on 2009-05-07
6
254 Views
Last Modified: 2012-05-06
Im developing a windows application (not web-based) using Visual Studio 2008 and Visual C#.

One of the projects within the solution builds into a DLL. One of the source files of this DLL contains a function as shown below;

extern "C" __declspec(dllexport) double* getTriggerWaveform_DLL(long channelNo, long noOfPoints, double* timeIncrement, double* startTime) throw(exception)
{
   // sample code
   int a = 2;
   a = a + 2;
}


Im trying to debug my solution but I am not being allowed to set a breakpoint in the code within this function. Instead I get the following message

"The breakpoint will not currently be hit. No symbols have been loaded for this document."

When I select the solution then do Project->Properties->Configuration Properties I note that the Platform for the DLL is set as "Win32" whereas all the other projects in the solution have Platform set to "Any CPU". Im not sure if that is significant.

Also note that Build is set to "Debug" for all the projects in the solution so that is not the reason.

I really need to be able to debug this function because my application hangs somewhere inside it !

Any ideas?
0
Comment
Question by:rangers99
  • 3
  • 3
6 Comments
 
LVL 16

Accepted Solution

by:
CuteBug earned 125 total points
ID: 24324398
When you try to attach to a process, Visual studio displays a dialog titled "Attach To Process"

1. Select the process you want to attach to.
2. In that dialog, in the "Attach To" section, there is a button called "Select". Click on that.
3. It shows up a new dialog.
4. Select the "Debug these code types" radio box.
5. From the list, select "Managed" and "Native".
6. Click OK.
7. Click Attach.
8. Now you should be able to set a breakpoint in your dll.


0
 

Author Comment

by:rangers99
ID: 24324880
CuteBug

Thanks for the reply.

Unfortunately I don' understand what you mean you say "Select the process you want to attach to". By process do you mean the DLL.
0
 
LVL 16

Expert Comment

by:CuteBug
ID: 24325005
When you start the application which uses your DLL, that application will be listed in the Attach to Process dialog.
Select that process...

By the way you must attach before your application call the DLL's method.
One way to do this is to add a MessageBox.Show("Attach"); before your DLL's method is called.

Once you have attached the debugger to the process, then you can click Ok on the message box that is displayed.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:rangers99
ID: 24325229
CuteBug

Thanks I tried that. Unfortunatley the process is greyed out and has a type of "Managed" (all the other processes listed have type x86). The "Attach" button is disabled for my process and I cant attach the debugger. Any way round this?
0
 
LVL 16

Expert Comment

by:CuteBug
ID: 24334902
Hi,
Sorry for the late reply.

If the process appears greyed out in your Attach to Process dialog, it means that you have already attached to that process.
(Could you please show a screenshot of the Attach to Process Dialog to confirm this?)

If that is the case then you can detach the process (the option is under Debug menu).

Now attach again using the method described in my previous comment.
0
 

Author Comment

by:rangers99
ID: 24336509
Fantastic, thanks Cutebug
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now