473,761 Members | 9,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 onCHostForWinFo rm, 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.StackOv erflowException ' 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 2696
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 'FatalExecution EngineError' has detected a
problem in 'd:\Program Development\Foo tAnalNovel\Ver
4.0.1\Debug\Foo tanalNovel.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 onCHostForWinFo rm, 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.StackOv erflowException ' 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
1717
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 the /noentry switch and an explicit initialisation procedure, to be able to safely use Managed C++ assemblies that call down into standard C library functions. Could someone confirm that I've understood this properly ? I'm writing some Managed...
0
1122
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 .NET web application. It mostly worked fine; however, periodically the ASPX pages would return an error trying to instantiate one of the classes in this assembly, which could then only be resolved by restarting the WWW service. Researching the...
11
1990
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. The control lists documents attached to an specific item. The control supports drag/drop and automatically uploads and downloads via an web service to an SQL server database. The control works fine when run on my develop machine. But if i try...
8
2696
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 dll into a console application (f.x StrongConsoleApp.exe) and run it if I have somehow specified the public part of the strong key and not otherwise.
10
2401
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 created a new CLR class library and added my native/unmanaged C++ code then added some code to the unmanaged class. Now, and this is where I am not sure, I turned off the CLR support in
2
1270
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: 1) What does the managed assembly look at to decide where to look for the unmanaged DLL dependencies? 2) Why do I run into difficulties running clients EXEs (e.g., VB) against the GAC based assembly?
20
6020
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 members / singletons (especially meyer type singletons) which use locally declared static variables. These variables are normally cleaned up automatically at shutdown of the application by registering with the atexit. I break point the destructor on...
3
5392
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: ijw/native module detected; cannot link with pure modules I am fine switching to CLR mode, but I have a question. If I build the control library DLL in CLR mode, will it still integrate seamlessly into C#/VB projects? Or will I have to change...
11
10150
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 seen erratic results. I am aware of one known defect where user classes do not show up in the list of types on the Property/Settings page in the visual designer and I am wondering if I am encountering some other peculiar issue, or if there are...
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.