473,473 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Create 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 1586

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

Similar topics

0
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
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
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
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
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
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
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
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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
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
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,...
0
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
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.