Debug Win32 DLL from C# Client

B

Bill Jones

I'm trying to setup a test jig where I can call an exported standard
Win32 dll from a C# exe. The program I am writing for requires a
standard Win32 dll but I want to initially test/debug the dll from a
C# client, if possible.

How can I set up Visual Studio (7.1) so that I can step the debugger
into the dll code from the C# code. Or as a minimum how can I break
in the dll code.

Now when I try to step into the dll function from c# it just steps
over it and it ignores any break points in the dll.

thanks
bill
 
N

Nicholas Paldino [.NET/C# MVP]

Bill,

Have you added the C++ code as a separate project in the solution?
Also, is that project configured for a debug build? Finally, is the C++
code configured to run and wait for a program to load it?

Hope this helps.
 
S

Shakir Hussain

Try this

Open project settings.

Go to Configuration Properties->Debugging

Set "Enable Unmanaged Debugging" to "True"

Shak.
 
B

Bill Jones

I set Enable Unmanaged Debugging to True. (as suggest by Shakir).
Still can't step into the dll.
Have you added the C++ code as a separate project in the solution?

Yes. I have a solution named TestDLLSol which holds projects TestDll1
and TestDLL1ClientCSharp.
Also, is that project configured for a debug build?

Yes, both.
Finally, is the C++ code configured to run and wait for a program to load it?

How do I do this?


Also, I copied TestDll1.dll into TestDLL1ClientCSharp\bin\Debug and I
set TestDLL1ClientCSharp as the Startup project.


thanks,
bill
 
S

Shakir Hussain

Alright Bill,

Try this definition for ur dll import. Make sure that you specify the full
path where the .pdb file is located. Now it shld debug after enabling the
project settings.

for example.

[DllImport(c:\test directory\test program\mydll.dll")]
public static extern TestFunction(blah, blah)

Shak.
 
B

Bill Jones

Bingo, that got it. It looks like the full path was the trick. Thank
you very much Mr. Shakir Huss.


Alright Bill,

Try this definition for ur dll import. Make sure that you specify the full
path where the .pdb file is located. Now it shld debug after enabling the
project settings.

for example.

[DllImport(c:\test directory\test program\mydll.dll")]
public static extern TestFunction(blah, blah)

Shak.


Bill Jones said:
I set Enable Unmanaged Debugging to True. (as suggest by Shakir).
Still can't step into the dll.


Yes. I have a solution named TestDLLSol which holds projects TestDll1
and TestDLL1ClientCSharp.


Yes, both.
it?

How do I do this?


Also, I copied TestDll1.dll into TestDLL1ClientCSharp\bin\Debug and I
set TestDLL1ClientCSharp as the Startup project.


thanks,
bill
 
S

Shakir Hussain

Anytime Bill.

Shak.

Bill Jones said:
Bingo, that got it. It looks like the full path was the trick. Thank
you very much Mr. Shakir Huss.


Alright Bill,

Try this definition for ur dll import. Make sure that you specify the full
path where the .pdb file is located. Now it shld debug after enabling the
project settings.

for example.

[DllImport(c:\test directory\test program\mydll.dll")]
public static extern TestFunction(blah, blah)

Shak.


Bill Jones said:
I set Enable Unmanaged Debugging to True. (as suggest by Shakir).
Still can't step into the dll.

Have you added the C++ code as a separate project in the solution?

Yes. I have a solution named TestDLLSol which holds projects TestDll1
and TestDLL1ClientCSharp.

Also, is that project configured for a debug build?

Yes, both.

Finally, is the C++ code configured to run and wait for a program to
load
it?
How do I do this?


Also, I copied TestDll1.dll into TestDLL1ClientCSharp\bin\Debug and I
set TestDLL1ClientCSharp as the Startup project.


thanks,
bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top