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.

Problems implementing MSDN Library example of a mixed assembly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Walsh - 02 Mar 2007 23:06 GMT
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
name> has 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
Jim Walsh - 06 Mar 2007 21:11 GMT
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

> 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
[quoted text clipped - 43 lines]
>
> Jim

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.