Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

How to debug a mixed assembly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Walsh - 07 Mar 2007 16:27 GMT
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
William DePalo [MVP VC++] - 07 Mar 2007 17:00 GMT
> I'm new to working with mixed assemblies. All of my previous experience
> has
[quoted text clipped - 10 lines]
> 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
Jim Walsh - 07 Mar 2007 17:32 GMT
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

> > I'm new to working with mixed assemblies. All of my previous experience
> > has
[quoted text clipped - 18 lines]
> Will
> www.ivrforbeginners.com 
William DePalo [MVP VC++] - 07 Mar 2007 18:52 GMT
> 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
Jim Walsh - 07 Mar 2007 20:53 GMT
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

> > Thanks for your quick reply to my posting.
>
[quoted text clipped - 23 lines]
> Will
> www.ivrforbeginners.com
William DePalo [MVP VC++] - 07 Mar 2007 22:39 GMT
> At this point I have gotten thoroughly mixed up. Let me review:
>
[quoted text clipped - 4 lines]
> 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
Jim Walsh - 07 Mar 2007 22:56 GMT
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

> > At this point I have gotten thoroughly mixed up. Let me review:
> >
[quoted text clipped - 21 lines]
> Will
> www.ivrforbeginners.com
William DePalo [MVP VC++] - 07 Mar 2007 23:31 GMT
> 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
[quoted text clipped - 3 lines]
> on
> there.

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

Regards,
Will

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.