views:

696

answers:

4

Hello,

I have a .dll from c++ and i want to debug it in Csharp, but i don't know how to do.

When i compiled the c++ project, Visual studio asked me to execute an ".exe"

I supposed that i had to create a project to execute the dll.

But i'm some lost, anyone have suggestions?

( sorry for my english, i'm french )

+2  A: 

Visual Studio cannot execute a dll on its own.

You need to set the startup .exe that will be using your C++ dll in the properties of your dll project. You can do so from properties --> debugging --> command specifying the path of the executable that's gonna call your dll and any command line argument needed.

JohnIdol
+2  A: 

If I understand you correctly, you want to debug a C++ coded DLL that you created, in a C# project that calls the DLL, which you also created?

I've done this before by going into your C# project properties, and under the Debug section, checking the "Enable unmanaged code debugging" check box. This should allow you to step into your C++ DLL.

CCicotta
A: 

Thanks for help !!

Yes, i want to debug a c++ coded dll ( i have all the project) in a c# project ( who calls this c++ dll ).

This dll was send to me in c++, but i'm csharp's developer.

It sounds obvious but here we go: You can't debug in C# if it's written in C++ - have a look at my suggestion, you might also have to enable unmanaged code debugging as suggested by @CCicotta.
JohnIdol
A: 

To debug a C++ from C# there a couple of things you have to do.

  1. Add a C# project to you solution for your debug application.
  2. Edit the properties of the C# project to "Allow unmanaged code debugging" on the "Debug" tab of the project properties.
  3. Set the C++ project as a dependency of the C# project.
  4. Write code in your C# project to use the DLL either using P/Invoke or COM.
  5. Set some breakpoints in your C++ code and run the C# project.
heavyd