473,395 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 1585

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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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...

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.