473,382 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problems implementing MSDN Library example of a mixed assembly

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
1 2664
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve Terepin | last post by:
I've found some rather worrying articles (Mixed Mode Library Assembly bug, Richard Grimes, Windows Developer Network Sept 2003 ; and Knowledge Base Article 814472 ) that point out the need to use...
0
by: MPadovani | last post by:
Thanks in advance for anyone reading this. I have a body of MFC C++ code that I put a managed C++ wrapper around (using VS 2003) to expose as a .NET assembly (as a set of public classes) for a...
11
by: John Boghossian | last post by:
I know this isnīt spot on for this group, but the problem relates to an asp.net project i am working on. I am trying to develop an windows forms control to be used in IE in an intranet solution....
8
by: per9000 | last post by:
Dear readers, I have some problems with strong keys. What I want to do is basically this. A - create an application (f.x. strongHello.dll) with a strong key. B - import the functions of this...
10
by: ajtaylor | last post by:
Hello, I have a load of native C++ code that I want to use in a CLR class library. My "logic" being that I create a C++/CLI managed class that acts as an interface to the unmanged code. I...
2
by: MC-Advantica | last post by:
I have a managed C++ based assembly referencing a bunch of unmanaged DLLs. I strongly name the the mixed assembly, and place it in the GAC. I write a VB client and reference the managed assembly:...
20
by: Aek | last post by:
We recently moved our large codebase over from VS7 to 8 and found that we now get access violations in atexit calls at shutdown when debugging the application in VS2005. This occurs in static...
3
by: dragonslayer008 | last post by:
I am building a control library in C++/CLI. My project links with a native library and am getting an error that the library cannot work with pure: dxerr.lib(dxerr.obj) : fatal error LNK1313:...
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.