title: Visual Studio Designer won't work for a C++/CLI file in VS2012 while it did in VS2005. Know why?
body: <p>I know, I know, this issue has been addressed many times. "Just forward declare your class before any other forward declarations and it will work."</p>
  
  <p>I re-open this question because for me it doesn't work at all. I have Visual Studio 2012 update 1. I develop in C++/CLI in x64 on Win 7/x64. Here is how my header file looks like:</p>
  
  <pre><code>#pragma once
  
  namespace MyNameSpace
  {
      ref class MyForwardDeclaredClass;
  
      public ref class MyClass : public System::Windows::Forms::UserControl
      {
      public:
          // My declaration here
  
          MyForwardDeclaredClass^ mObjectPtr;
      }
  }
  </code></pre>
  
  <p>When I launch the design, I get the message <strong>The class MyClass can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file.</strong> </p>
  
  <p>So, following the recommendations of many persons (and these recommendations seem to work for many), I added the line:</p>
  
  <pre><code>ref class MyClass; // &lt;-- ADDED FORWARD DECLARATION HERE!
  ref class MyForwardDeclaredClass;
  
  public ref class MyClass : public System::Windows::Forms::UserControl
  {
      // ...
  </code></pre>
  
  <p>and I still get the same error message. Notice that <em>I also restarted Visual Studio</em>, <em>I cleaned the project</em>, and <em>I rebuilt it</em>.    </p>
  
  <p>Note: I tried to remove the forward declaration and to add a #include "MyForwardDeclaredClass.h" instead. I got the same error.</p>
  
  <p>We migrated from VS2005 to VS2012 recently. With VS2005, the designer use was so-so. But it worked most of the time. Now, most of the time I cannot make it work and I don't find any workaround. </p>
  
  <p>Any idea?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>OK, following the advices I was given, I erased the .suo and the .sdf files then reloaded the solution then rebuilt it. Nothing good. I recreate a new project using the same code files: nothing good. And yes, <em>I have .cpp files in my project</em> ;-) </p>