Groups | Blog | Home
all groups > dotnet interop > november 2004 >

dotnet interop : Problem referencing Managed class from the Unmanaged (beginner question)


Sasha Nikolic
11/25/2004 2:38:14 PM
I have a managed ( __gc ) class and a unmanaged ( __nogc ) class in the same
VC++ 2003 project (since I need to create a dotnet wrapper for some old c
library code). I can easily reference unmanaged class from the managed one,
but I'm having problems when I need to call managed class method from the
unmanaged class.

I have tried gcroot but I got into problems:

- When I just tried placing something like
gcroot<ManagedClass*> m_pManagedClass;
I got error C2065: 'ManagedClass' : undeclared identifier.

- OK, unmanaged class was missing definition of the managed one so I added
one include in the unmanaged class header file :
#include ".\ManagedClass.h"
This gave some syntax errors in the ManagedClass.h (which was compiling OK
before).


Does anybody have some ideas how can I reference the managed class from the
unmanaged? I just need to call one method.

Is there a better way of doing this.

Thanks a lot,
Sasha

Sasha Nikolic
11/25/2004 3:59:09 PM
From the UnmanagedClass.cpp file I can easily use System::* namespaces and
implement those objects but if I specify:

using namespace ManagedNamespace;

I get the error:

error C2871: 'ManagedNamespace' : a namespace with this name does not exist

Any help appreciated!

Cheers,
Sasha


[quoted text, click to view]

AddThis Social Bookmark Button