Solved

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

Posted on 2009-05-07
6
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
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.

724 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