How to debug a mixed assembly

G

Guest

I'm new to working with mixed assemblies. All of my previous experience has
been with VC++/MFC in native, unmanaged applications.

When I create a mixed assembly in which one or more of the files compiles
with /clr the instructions say that I need to change the switch for Debug
information format from Program Database for Edit & Continue to disabled.

At runtime I find that I am not able to set breakpoints in the managed code,
nor trace into it.

Is there someway to debug both the managed and unmanaged parts of a mixed
assembly?

Thanks,
Jim
 
W

William DePalo [MVP VC++]

Jim Walsh said:
I'm new to working with mixed assemblies. All of my previous experience
has
been with VC++/MFC in native, unmanaged applications.

When I create a mixed assembly in which one or more of the files compiles
with /clr the instructions say that I need to change the switch for Debug
information format from Program Database for Edit & Continue to disabled.

At runtime I find that I am not able to set breakpoints in the managed
code,
nor trace into it.

Is there someway to debug both the managed and unmanaged parts of a mixed
assembly?

Are you using VS2003 or VS2005? Did you turn off the edit-and-continue
option but continue to generate the PDB file? Have you tried setting the
debugger type to "mixed" rather than "auto"?

Regards,
Will
www.ivrforbeginners.com
 
G

Guest

William,

Thanks for your quick reply to my posting.

1. I am using VS2005.

2. Debugger type is set to Auto - I will change this to mixed.

3. "Did you turn off the edit-and-continue option but continue to generate
the PDB file?" I don't know the answer to this question...I am new to managed
code.

Jim
 
W

William DePalo [MVP VC++]

Jim Walsh said:
Thanks for your quick reply to my posting.

You are welcome.
1. I am using VS2005.

OK. I asked because 2003 sometimes has difficulty in "auto" debug mode. The
only mixed mode project I have is built with it and not 2005 so I don't know
if that has a bearing.
2. Debugger type is set to Auto - I will change this to mixed.

As long as you have a mixed-mode project I don't think it can hurt.
3. "Did you turn off the edit-and-continue option but continue to generate
the PDB file?" I don't know the answer to this question...I am new to
managed
code.

OK. Choose Properties from the Project Menu. Then in the left pane make sure
that the C++ options are expanded (click on the + sign if necessary). Select
the General item. In the right pane look for Debug Information Format.
Change to Program Database and rebuild your project.

Regards,
Will
www.ivrforbeginners.com
 
G

Guest

William,

At this point I have gotten thoroughly mixed up. Let me review:

I have two projects, one dependent on the other:

1. The first project is my Visual C++ program. I am compiling this project
as unmanaged, native, except for two modules. In the project properties, I
have set "No common Language Runtime support", Debug Information Format =
"Program Database for Edit & Continue (/ZI)", and Debugger Type = mixed.

There are two files in this project that I am compiling with /clr. For
these, I have set Debug Information Format = disabled. One of these files
uses a dialog class defined in the 2nd project.

2. The second project was created from the example in the MSDN Library
entitled "Hosting a Windows Form User Control in an MFC Dialog box". This is
a Visual C# Windows control library project. It creates a a Windows Form User
control that will be hosted in the MFC dialog box.

For this 2nd project, I have set Debugger type = Mixed, Debug Information
Format to Program database (/Zi), and Common Language Runtime support to
"Pure MSIL Common Languare runtime support (/clr:pure).

Are these settings correct?

Thanks,
Jim
 
W

William DePalo [MVP VC++]

Jim Walsh said:
At this point I have gotten thoroughly mixed up. Let me review:

I have two projects, one dependent on the other:

1. The first project is my Visual C++ program. I am compiling this project
as unmanaged, native, except for two modules. In the project properties, I
have set "No common Language Runtime support", Debug Information Format =
"Program Database for Edit & Continue (/ZI)", and Debugger Type = mixed.

I thought you started this thread by saying you needed to disable edit and
continue. To be honest, I can't tell you whether it is strictly necessary in
your case because I _always_ turn the option off. I always turn off
incremental linking as well.
There are two files in this project that I am compiling with /clr. For
these, I have set Debug Information Format = disabled. One of these files
uses a dialog class defined in the 2nd project.

I can't see how you'll be able to debug at the source code level if you turn
off debug information. Is the problem that you are unable to debug the
module for which you disabled debug information?

Regards,
Will
www.ivrforbeginners.com
 
G

Guest

Will,

I actually have the debugging part of this working.

Working with mixed assemblies really is tricky. But, I have finally figured
out a consistent set of switches that enable me to get debugging information.
The project settings that I have come up with are:

Debugger Type - Mixed
Debug Information Format: Program Database (/Zi)
Runtime Library: Multi-threaded Debug DLL (/MDd)
Precompiled Headers: Not using Precompiled Headers
Enable Minimal Rebuild: No
Enable C++ Exceptions: Yes with SEH Exceptions (/EHa)

This now compiles, and I can set breakpoints in both the unmanaged and
managed code, and trace from the unmanaged into the managed code.

New problem (actually an old problem) I have posted separately. The program
seems to run fine, but when I exit, I get an error in DomainUnload, when it
calls the function UninitializeAppDomain(). I have no idea what is going on
there.

Thanks again for your advice.
Jim
 
W

William DePalo [MVP VC++]

Jim Walsh said:
This now compiles, and I can set breakpoints in both the unmanaged and
managed code, and trace from the unmanaged into the managed code.
Congratulations.

New problem (actually an old problem) I have posted separately. The
program
seems to run fine, but when I exit, I get an error in DomainUnload, when
it
calls the function UninitializeAppDomain(). I have no idea what is going
on
there.

I can't say that anything rings a bell. Sorry.

Regards,
Will
 

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

Top