Hi,
I try to use a C# Dialog in a legacy MFC application.
The problem seems to boil down to the following:
from an unmanaged console application I can call any function of the managed
bridge - if I try to do the same from my mfc application the application
won't start
'SeaMain.exe': 'E:\WINDOWS\sys tem32\mscoree.d ll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\msvcr71d. dll' geladen, Symbole geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\mfc71d.dl l' geladen, Symbole geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\gdi32.dll ' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\user32.dl l' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\shlwapi.d ll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\advapi32. dll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\rpcrt4.dl l' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\msvcrt.dl l' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\comctl32. dll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\oleaut32. dll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\ole32.dll ' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\msvcp71d. dll' geladen, Symbole geladen.
Eine Ausnahme (erste Chance) bei 0x7c928fea in SeaMain.exe: 0xC0000005:
Zugriffsverletz ung-Schreibposition 0x00000010.
Eine Ausnahme (erste Chance) bei 0x7c974ed1 in SeaMain.exe: 0xC0000005:
Access violation.
From what I have found in the net I conclude that calling managed code from
unmanaged code in an MFC application requires hosting the CLR somehow using
CorBindToRuntim eEx
Moreover it looks as if I have to use COM interop in that case.
If these conclusion are wrong, (which I silently hope) how can I call into
managed dll from an unmanaged MFC application?
Thanks in advance,
Arne 1 2258
"Arne Adams" <ar********@t-online.dewrote in message
news:ej******** *****@news.t-online.com...
Hi,
I try to use a C# Dialog in a legacy MFC application.
The problem seems to boil down to the following:
from an unmanaged console application I can call any function of the
managed bridge - if I try to do the same from my mfc application the
application won't start
'SeaMain.exe': 'E:\WINDOWS\sys tem32\mscoree.d ll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\msvcr71d. dll' geladen, Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\mfc71d.dl l' geladen, Symbole geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\gdi32.dll ' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\user32.dl l' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\shlwapi.d ll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\advapi32. dll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\rpcrt4.dl l' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\msvcrt.dl l' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\comctl32. dll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\oleaut32. dll' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\ole32.dll ' geladen, Keine Symbole
geladen.
'SeaMain.exe': 'E:\WINDOWS\sys tem32\msvcp71d. dll' geladen, Symbole
geladen.
Eine Ausnahme (erste Chance) bei 0x7c928fea in SeaMain.exe: 0xC0000005:
Zugriffsverletz ung-Schreibposition 0x00000010.
Eine Ausnahme (erste Chance) bei 0x7c974ed1 in SeaMain.exe: 0xC0000005:
Access violation.
From what I have found in the net I conclude that calling managed code
from unmanaged code in an MFC application requires hosting the CLR somehow
using
CorBindToRuntim eEx
Moreover it looks as if I have to use COM interop in that case.
If these conclusion are wrong, (which I silently hope) how can I call into
managed dll from an unmanaged MFC application?
Thanks in advance,
Arne
1) There is no need to call CorBindToRuntim eEx manually.
2) Choose the /Zi compiler switch for your whole project
3) Add a new file to your project.
4) Modify the following property switches for the file
set /clr (mixed code compilation model)
set /EHa (async exceptions)
don't set /Gm, /RTC1 (non minimal rebuild, no runtime checks)
don't use /Yu (precompiled header)
5) In your file write something like this
#using "MyCSharpUIDLL. dll"
void ShowCSharpDialo g()
{
MyCSharpDialog dlg = __gc new MyCSharpDialog( );
dlg.ShowDialog( );
}
6) Call that functin from your code
HTH
Marcus Heege This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bryan |
last post by:
I have a multi-threaded C# console application that uses WMI
(System.Management namespace) to make RPC calls to several servers (600+ )
and returns ScheduledJobs. The section of my code that performs the query
is contained in a delegate function that I execute via a second thread. On 1
or 2 of the 600+ servers the query hangs. I've tried to use Thread.Join()
coupled with a Thread.Abort() but this does not kill the thread.
Based on...
|
by: Fender Mussel |
last post by:
Hi,
We are in a situation where we have a Win32 application which is
currently deployed to about 15000 desktop machines and want to rewrite
the back end (business logic) in a modern language. At the moment there
is no change for changing the front end (GUI) because it's far to
complex to rewrite it now.
Thus, we are currently evaluating several alternatives for programming
languages and one very favourite candidate is C#.
|
by: Jesse McGrew |
last post by:
Hi all,
I'm trying to make a plugin DLL for a third-party application, using
VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of
the application, and my actual plugin code written in C#.
When the app calls my unmanaged functions, they work fine. But as soon
as my unmanaged functions call managed functions (in the same source
file!), the app reports an "unknown exception" error.
|
by: H.B. |
last post by:
Hi,
I need to make a function that can display data on my Managed C++ app and be
called by an unmanaged C++ DLL. Something like :
void Form1::Form1_Load(System::Object * sender, System::EventArgs * e)
{
MyDLLInit(MyAppDisplayFunction);
}
|
by: monika.saxena |
last post by:
Hi all,
In one of my projects which is a web based application in asp.net, a
third party tool - "Frontline Solver DLL" (It is an unmanaged DLL and
..NET is calling it using the PInvoke) is used. This DLL is used for
solving and optimizing some non linear problems.
Problem : The problem I am facing is as the solver runs and does the
| |
by: MC-Advantica |
last post by:
Does anyone have a simple "Hello World" like application that demonstrates
unmanaged C++ calling managed C++ developed in VS2005? I'm confused by many
posts as they discuss managed extensions from VS2003, and related techniques.
I have found managed to unmanaged technique very easy in VS2005, but have
not been able to build anything with unmanaged to managed calls. I have
legacy (unmanaged C++) that would like to leverage the .NET...
|
by: Amit Dedhia |
last post by:
Hi All
I have a VC++ 2005 MFC application with all classes defined as
unmanaged classes. I want to write my application data in xml format.
Since ADO.NET has buit in functions available for this, I want to use
it. Is it possible to call Managed class functions from Unmanaged
class? How to do it?
I did something like this.
I declared a managed class (in C++ CLI) called as MyManagedClass whose
|
by: Klaus |
last post by:
Hi,
I have an existing VC 6 MFC application which communicates asynchronly with
a VC 2005 managed code dll.
I use an unmanaged base class with virtual functions to access methods in
the MFC application.
Furthermore, I use a pointer to an unmanaged function to jump back into the
managed dll.
The managed part is basically a remoting enhancement which asynchronly
|
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= |
last post by:
I have a C# logging assembly with a static constructor and methods that is
called from another C# Assembly that is used as a COM interface for a VB6
Application. Ideally I need to build a file name based on the name of the
VB6 application. A second choice would be a file name based on the # COM
interface assembly. I have tried calling Assembly.GetCallingAssembly() but
this fails when I use the VB6 client. Is there a way to get this...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |