title: Create Managed Object From Unmanaged Class Function
body: <p>I am trying to create a Managed C++/CLI object in unmanaged code.</p>
  
  <ol>
  <li>Is this possible?</li>
  <li><p>If so, am I doing it right? see code below</p>
  
  <pre><code>#include &lt;vcclr.h&gt;
  #include &lt;ManagedClass.h&gt;
  
  // compiled with /clr
  namespace X 
  {
      class UnmanagedClass
      {
          UnmanagedClass(){}
          ~UnmanagedClass(){}
  
          gcroot&lt;Y::ManagedClass^&gt; m_guiControl;
  
          void functionA()
          {
               m_guiControl = new gcroot&lt;Y::ManagedClass^&gt;;
          }
      }
  }
  
  // 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
  
      }
  }
  </code></pre></li>
  </ol>
  
  <p>When I compile the <code>UnmanagedClass</code> source file, I keep getting a whole lot of errors with the first one being <code>error C2039: 'ComponentModel' : is not a member of 'System'</code>. How come it is not recognising <code>ComponentModel</code>?</p>
  
  <p>I thought this was suppose to be IJW (it just works) ;-)</p>