By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,316 Members | 2,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,316 IT Pros & Developers. It's quick & easy.

Problems implementing MSDN Library example of a mixed assembly

P: n/a
I have an VC++ MFC Win32 application that isn't working correctly when I
build it with VS2005. The problem seems to be in some ADO ActiveX controls
that came with VS6 and are now out of support. So, I have decided to solve
the problem by using a mixed assembly: Most of the program will be my MFC -
based code (unmanaged), but I will implement one dialog box as managed code.
In my original MFC app, this dialog box contains the problem ActiveX
controls. In the mixed assembly, the dialog box will use the new controls
that are available to .NET apps.

The Visual Studio documentation has an example that describes this
situation: "Hosting a Windows Form User Control as an MFC Dialog Box".

I have implemented the dialog box that is described there in my mixed
assembly. At this point, I just used the button and textbox controls in the
dialog, as described in the example. Basically, my mixed assembly application
works, but I have some questions / problems with this:

1. The example has a class named CHostForWinForm that is based on an MFC
template class named CWinFormsDialog. The example says that if I right click
on CHostForWinForm in the VS2005 Class View, select properties, I will will
see a list of properties, events, messages, and overrides. (I need to
override OnInitDialog.) But, when I right click onCHostForWinForm, all I see
is the list of properties. The Events, Messages, and Overrides lists are
empty.

I can bypass this, and manually insert the override into the code, and this
works just fine. But, why don't I see them in the properties of the class in
Class view?

2. The mixed assembly seems to run fine. I see the dialog. As in the
example, I can click on the button, or enter text into the textbox, and the
MFC host handles it fine. I close the dialog by clicking on the X in the top
right corner, and I am returned to my app. However, when I close the app
itself, I get an error. It's that standard Windows error about " <my program
namehas encountered a problem and needs to close. We are sorry for the
inconvenience." Then asks about sending a report. If I run the program under
the debugger, when I close the app, I get the message "An unhandled exception
of type 'System.StackOverflowException' occurred in mscorlib.dll." Any idea
what is causing this?

3. I am not able to set breakpoints in the code that is being compiled with
/clr. How can I set this up so that I can debug both the unmanaged and the
managed parts of the program?

Thanks for your help.

Jim

Mar 2 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
This is a follow-up to my original posting.

When I run this app under the debugger the error message that I get when I
do File...Exit to end the program is:

Managed Debugging Assistant 'FatalExecutionEngineError' has detected a
problem in 'd:\Program Development\FootAnalNovel\Ver
4.0.1\Debug\FootanalNovel.exe'.
Additional Information: The runtime has encountered a fatal error. The
address of the error was at 0x7c812a5b, on thread 0x144. The error code is
0x800703e9. This error may be a bug in the CLR or in the unsafe or
non-verifiable portions of user code. Common sources of this bug include user
marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

The stack trace shows that I am in MFCM80D.DLL. The source code window show
that this is in MSTARTUP.CPP line 756 in function DomainUnload().

In an attemp to see what is causing this error. I have tried starting the
application and then immediately exiting. I still get the same error. In this
procedure, I am sure that I have not executed any of the managed part of this
mixed assembly.

I would appreciate help in getting this work.

Thanks,
Jim
"Jim Walsh" wrote:
I have an VC++ MFC Win32 application that isn't working correctly when I
build it with VS2005. The problem seems to be in some ADO ActiveX controls
that came with VS6 and are now out of support. So, I have decided to solve
the problem by using a mixed assembly: Most of the program will be my MFC -
based code (unmanaged), but I will implement one dialog box as managed code.
In my original MFC app, this dialog box contains the problem ActiveX
controls. In the mixed assembly, the dialog box will use the new controls
that are available to .NET apps.

The Visual Studio documentation has an example that describes this
situation: "Hosting a Windows Form User Control as an MFC Dialog Box".

I have implemented the dialog box that is described there in my mixed
assembly. At this point, I just used the button and textbox controls in the
dialog, as described in the example. Basically, my mixed assembly application
works, but I have some questions / problems with this:

1. The example has a class named CHostForWinForm that is based on an MFC
template class named CWinFormsDialog. The example says that if I right click
on CHostForWinForm in the VS2005 Class View, select properties, I will will
see a list of properties, events, messages, and overrides. (I need to
override OnInitDialog.) But, when I right click onCHostForWinForm, all I see
is the list of properties. The Events, Messages, and Overrides lists are
empty.

I can bypass this, and manually insert the override into the code, and this
works just fine. But, why don't I see them in the properties of the class in
Class view?

2. The mixed assembly seems to run fine. I see the dialog. As in the
example, I can click on the button, or enter text into the textbox, and the
MFC host handles it fine. I close the dialog by clicking on the X in the top
right corner, and I am returned to my app. However, when I close the app
itself, I get an error. It's that standard Windows error about " <my program
namehas encountered a problem and needs to close. We are sorry for the
inconvenience." Then asks about sending a report. If I run the program under
the debugger, when I close the app, I get the message "An unhandled exception
of type 'System.StackOverflowException' occurred in mscorlib.dll." Any idea
what is causing this?

3. I am not able to set breakpoints in the code that is being compiled with
/clr. How can I set this up so that I can debug both the unmanaged and the
managed parts of the program?

Thanks for your help.

Jim
Mar 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.