Link to home
Start Free TrialLog in
Avatar of rangers99
rangers99

asked on

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

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?
ASKER CERTIFIED SOLUTION
Avatar of CuteBug
CuteBug
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rangers99
rangers99

ASKER

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.
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.
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?
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.
Fantastic, thanks Cutebug