473,569 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

gcroot and mixed mode class lib

Hi All,

I've run into a problem, converting a native project
into mixed mode, where usage of gcroot point in mixed mode
causes a fatal CLR engine exception.

Here is a tiny code extract:
------------------ mixeddll.cpp ----------
#include <vcclr.h>

namespace testDLL
{
public __gc class CManagedSink;

gcroot<CManaged Sink*> g_pManagedSink;

public __gc class CManagedSink
{
public:
CManagedSink() {
g_pManagedSink = this;
}
};
}
--------------- end mixeddll.cpp -------------
--------------- main.cs-----------------------
using System;
namespace FailExampleNS
{
class FailExample
{
[STAThread] static void Main(string[] args)
{
testDLL.CManage dSink t =
new testDLL.CManage dSink();
System.Console. ReadLine();
}
}
}
--------------- end main.cs -----------------

Compile mixeddll by the rules in "Converting Managed Extensions for C++
Projects from Pure
Intermediate Language to Mixed Mode", i.e.,
cl /D "WIN32" /D "_WINDLL" /D "_MBCS" /FD /EHsc /MTd /GS /W3 /c /Zi
/clr /TP /FU "C:\WINNT\Micro soft.NET\Framew ork\v1.1.4322\m scorlib.dll"
/FU "C:\WINNT\Micro soft.NET\Framew ork\v1.1.4322\S ystem.dll" /FU
"C:\WINNT\Micro soft.NET\Framew ork\v1.1.4322\S ystem.Data.dll" /Zl
mixeddll.cpp
link /INCREMENTAL /DLL /INCLUDE:"__DllM ainCRTStartup@1 2" /ASSEMBLYDEBUG
/FIXED:No /noentry mscoree.lib msvcrt.LIB mixeddll.obj

Compile the c# exe:
csc /t:exe /out:main.exe /reference:mixed dll.dll main.cs

Run the main.exe and behold the exception.
You could comment out the "g_pManaged Sink = this" line, and see that
the exception
goes away.

I'm using VS.NET 2003 (.net ver 1.1.4322, cl ver 13.10.3077, csc ver
7.10.3052.4).
What would you suggest ?

Thanks for any help or suggestion, Igal

Aug 14 '05 #1
0 1606

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

Similar topics

0
1661
by: Edward Diener | last post by:
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". 1) The first instruction in converting to mixed mode is to link with /NOENTRY. This occurs despite the fact...
9
2575
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++...
8
3494
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I cannot load/unload/reload extensions into my large and slow-to-load application during development without restarting the process then the...
8
1980
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid the usage of old style COM, my alternative is to expose my unmanaged interface through the CLI, to achieve that I have created a mixed mode DLL in...
0
193
by: igal.ioffe | last post by:
Hi All, I've run into a problem, converting a native project into mixed mode, where usage of gcroot point in mixed mode causes a fatal CLR engine exception. Here is a tiny code extract: ------------------ mixeddll.cpp ---------- #include <vcclr.h>
4
2227
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....
8
2302
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR types. The problem: I have a number of mixed-mode functions which I want reuse. These functions revolve around converting a CLR String to a C++...
7
3082
by: | last post by:
All, I have a MFC Mixed mode dll which is working well. I am now tring to use a regular C++ class from another DLL which has a method called GetMessage. When I link I get 2 error messages: MyClass.obj : error LNK2028: unresolved token (0A00074C) "public: class CMessage * __thiscall CTransmitMessage::GetMessage(int)"...
6
4572
by: =?Utf-8?B?RmFiaWFu?= | last post by:
Hello, I have a class hierarchy distributed over 3 native C++ dlls. The base class has a .NET Windows.Form for status output via a gcroot<>. The gcroot is declared private - the sub classes only have access via a protected "print"-method. I need the different dlls as the sub classes implement the base class's pure virtual methods using...
0
7703
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...
0
7618
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...
0
8132
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...
1
7678
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...
1
5514
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...
0
5222
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...
0
3656
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...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
944
bsmnconsultancy
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...

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.