L
Lonewolf
Hi everyone..
I was trying to implement callback fucntions in native codes in my
VC8 class, and referred to some online codes which use native class
nested within managed class. basically of the form,
__gc class CManagedClass
{
__nogc CNativeClass
{
//blah blah blah
};
};
I tried to replocate the same thing using C++/CLI, but failed. I force
the compiler to use /clr:ldsyntax and was able to compile with
problem. So it seems the problem only appear in VC8 and worked on VC7.
my C++/CLI equivalent of the same code is as follows,
public ref class CManagedClass
{
class CNativeClass
{
//blah blah blah
};
};
setting to value also does not work. And I need it in ref as this is a
..NET wrapper for the native codes, and it compiled into a .NET assembly.
The compilation failed with the error, C2814: A native type cannot be
nested within a managed type. So obviously, by not putting the __nogc,
it is treating the CNativeClass as a native class indeed and the
compiler is complaining about it. So, in VC8, what is the work around
for this issue? It cannot be that the change to VC8 prevents callback
mechanism from native codes to managed codes. Doing so will break many
old codes which use things like event sinks and even the win32 API
EnumWindow which is often used as an example of native callback in .NET.
Can someone please enlighten me ?
I was trying to implement callback fucntions in native codes in my
VC8 class, and referred to some online codes which use native class
nested within managed class. basically of the form,
__gc class CManagedClass
{
__nogc CNativeClass
{
//blah blah blah
};
};
I tried to replocate the same thing using C++/CLI, but failed. I force
the compiler to use /clr:ldsyntax and was able to compile with
problem. So it seems the problem only appear in VC8 and worked on VC7.
my C++/CLI equivalent of the same code is as follows,
public ref class CManagedClass
{
class CNativeClass
{
//blah blah blah
};
};
setting to value also does not work. And I need it in ref as this is a
..NET wrapper for the native codes, and it compiled into a .NET assembly.
The compilation failed with the error, C2814: A native type cannot be
nested within a managed type. So obviously, by not putting the __nogc,
it is treating the CNativeClass as a native class indeed and the
compiler is complaining about it. So, in VC8, what is the work around
for this issue? It cannot be that the change to VC8 prevents callback
mechanism from native codes to managed codes. Doing so will break many
old codes which use things like event sinks and even the win32 API
EnumWindow which is often used as an example of native callback in .NET.
Can someone please enlighten me ?