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