473,799 Members | 2,927 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

\CLR Mixed mode compilation woes!

Iv compiled my current C++ project as \clr as i want to start putting
in some specific C++\CLI code to serialize my MFC objects to .NET
equivalents.
The program crashes on startup, something to do with the stack frame
being corrupted.

My first concern is the program has ballooned in terms of the size of
the executable image.
When it attempts to run it fails and some report about stack frame
corruption.

Iv noticed any C files have to be converted to C++.

The program links to a DLL and Libs that have been compiled as C.

Is this a problem when compiling a program as /CLR that then links with
C libs etc and on startup loads C Dlls?

How can i specifically instruct the compiler to only compiler specific
functions/methods as managed(mixed mode) and to leave everything else
as native?
Is this possible?

Thanks in advance.

Dec 7 '05
12 4612
Can anyone help me on this?
it has become a real show stopper!

How can i reference umanaged types derived from the MFC CObject within
a managed module?

I thought this was a big selling point of the mixed mode approach?

Dec 9 '05 #11
Yes I can help myself. I 'managed' to do it.

<code>
#include <afx.h> // MFC core and standard components
#include<afxtem pl.h>

#pragma managed(push, off)
#include"map_dw o.h"
#include"Runtim eMap.h"
#include"Conver t2DotNet.h"
#pragma managed(pop)

#using<Runtime2 .DLL>

using namespace Runtime2;

bool Convert2DotNet( CRuntimeMap* pMap)
{
RuntimeMap^ pGcMap = gcnew RuntimeMap;
return true;
}
</code>

Had to exclude the system headers outside of the un-managed set.

All systems go!

Dec 9 '05 #12
Ok..
Given an unmanaged class is it possible for one of its methods to be
compiled as managed?

The reason being im copying member data from the source unmanaged
object to the new managed target object. I would like direct acces to
this source member data via one of its methods.
Ideally all my current un-managed classes that must take part in the
..NET converison will implement the Convert2DotNet method( preferably
via an iterface class, but lets keep it simple as possible for now)

E.g.

#pragma managed
CRuntimeMap::Co nvert2DotNet(vo id)
{
}

When i attempt to do this i get the following error

error C3295: '#pragma managed' can only be used at global or namespace
scope

Is there anyway to acheive this?

Dec 9 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2592
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and explain it. I have some questions about the instructions for creating a mixed mode DLL in the MSDN topic "Converting Managed Extensions for C++ Projects from Pure Intermediate Language to Mixed Mode" in the "Managed Extensions for C++ Reference"....
13
4151
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make sense to punch out from managed code to native code (I was using IJW) in order to do some amount of floating point work and, if so, what that certain amount of floating point work was approximately. To attempt to do this I made a program that...
0
1004
by: bonk | last post by:
I have a plain unmanaged exe (no /CLR) that is supposed to to use classes from a mixed mode dll (dll that uses .NET internally). That dll only needs to expose unmanaged interfaces (classes and/or functions). This is of course no problem and it works fine. However I have the special scenario where the exe needs to be able to run even when there is no .NET Framework installed. The exe is supposed to check at runtime if the .NET Framework is...
5
3278
by: bonk | last post by:
I have a plain unmanaged exe (no /CLR) that is supposed to to use classes from a mixed mode dll (dll that uses .NET internally). That dll only needs to expose unmanaged interfaces (classes and/or functions). This is of course no problem and it works fine. However I have the special scenario where the exe needs to be able to run even when there is no .NET Framework installed. The exe is supposed to check at runtime if the .NET Framework is...
4
2243
by: Lonewolf | last post by:
hi, I'm still in the process of transiting from MFC/VC6 to vs2005, and a lot of things are very alien to me. So hope you could bear with me if my question sounds stupid. Basically I have native codes written in VC6 which I want to encapsulate in a managed assembly using C++/CLI so that I can use it in C# easily without all the interop codes. So, my question is, what is the replacement for MFC's TRACE macro in VS2005's C++/CLI in...
0
1414
by: Russ Barrett | last post by:
Hello, I'm new to ASP.Net and I'm trying to interface an ASP.Net (C#) application to functionality resident in a C++ static lib. From posts I've seen around I understand this requires creation of a 'mixed-mode' assembly. Since a dll of this type provides no normal entry point for C Runtime (CRT) library initialization, I understand that the dll must provide its own exported functions to do this. Thus, from samples I've seen on the web,...
5
1463
by: Bart | last post by:
Hi, What is the benefit of using the Pure option over the Mixed one. Is there a better performance? We have a lot of stuff in c++ with mfc support en we want to use in our .net apps. With mixed setting we can compile including the mfc part of our code. We can get rid of the mfc code but it will cost us some effort so we can use the pure setting in that case.
5
1786
by: Jesper Schmidt | last post by:
Hi, I have a relatively large C++ code base, which requires that static initializers are called when a dll is loaded. This seems to work well for native code, but it does not work for files compiled with the /CLR option enabled. I will try to give a simple example that illustrates my problem. Library code: -----------
6
6201
by: R.Kaiser | last post by:
I know that I can call Win32 API functions in a Windows forms application by specifying each function header individually like in using namespace System; using namespace System::Runtime::InteropServices; typedef void* HWND; extern "C" int* MessageBox(HWND hWnd, char* pText,
0
9687
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
9541
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
10251
jinu1996
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...
0
10027
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
9072
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...
0
6805
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();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
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
2
3759
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.