473,507 Members | 6,727 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<CManagedSink*> 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.CManagedSink t =
new testDLL.CManagedSink();
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\Microsoft.NET\Framework\v1.1.4322\mscorl ib.dll"
/FU "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System .dll" /FU
"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System .Data.dll" /Zl
mixeddll.cpp
link /INCREMENTAL /DLL /INCLUDE:"__DllMainCRTStartup@12" /ASSEMBLYDEBUG
/FIXED:No /noentry mscoree.lib msvcrt.LIB mixeddll.obj

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

Run the main.exe and behold the exception.
You could comment out the "g_pManagedSink = 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 1595

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

Similar topics

0
1649
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...
9
2569
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...
8
3485
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...
8
1971
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...
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:...
4
2214
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...
8
2299
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...
7
3079
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: ...
6
4562
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...
0
7221
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,...
0
7313
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,...
0
7372
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...
1
7029
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...
0
7481
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...
0
4702
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
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...

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.