I am trying to create a Managed C++/CLI object in unmanaged code.
- Is this possible?
If so, am I doing it right? see code below
#include <vcclr.h> #include <ManagedClass.h> // compiled with /clr namespace X { class UnmanagedClass { UnmanagedClass(){} ~UnmanagedClass(){} gcroot<Y::ManagedClass^> m_guiControl; void functionA() { m_guiControl = new gcroot<Y::ManagedClass^>; } } } // compiled into Managed dll with /clr // in file ManagedClass.h in a separate project using namespace System::ComponentModel; // more usings here ..etc namespace Y { public ref class ManagedClass : public System::Windows::Forms::UserControl { // implementation here } }
When I compile the UnmanagedClass
source file, I keep getting a whole lot of errors with the first one being error C2039: 'ComponentModel' : is not a member of 'System'
. How come it is not recognising ComponentModel
?
I thought this was suppose to be IJW (it just works) ;-)