title: How to access class in C++/CLI from C#?
body: <p>I am writing a GUI tool in C# to parse and display the data output of another program written in C.  In order to parse the data I need to know the data structures which are specified in a number of C header files.  Thus I need to incorporate those C header files into my C# project.  My questions are:</p>
  
  <p>1) After some research I came to conclude that the best way is to create a new C++/CLI project in my solution, import the C header files into this new project, write some C++/CLI classes that act as thin wrappers for the data structures defined in the C header files, then reference the C++/CLI wrapper classes from the C# code.  Is this the best approach, or is there a better way?</p>
  
  <p>2) I ran into a reference problem.  Here's my simplified code to illustrate the problem:</p>
  
  <p>Original C header in C++/CLI project</p>
  
  <pre><code>#define ABC  0x12345
  </code></pre>
  
  <p>Wrapper class in C++/CLI project</p>
  
  <pre><code>#include "my_c_header.h"
  
  namespace C_Wrappers {
      public ref class MyWrapper {
          public:
              property unsigned int C_ABC {
                  unsigned int get() { return ABC; }
              }
      }
   }
  </code></pre>
  
  <p>User class in C# project</p>
  
  <pre><code>using C_Wrappers;
  using System;
  
  namespace DataViewer {
      public partial class MainForm : Form {
          private  MyWrapper myWrapper = new MyWrapper();
          public MainForm() {
              Console.WriteLine(myWrapper.C_ABC.ToString());
          }
      }
   }
  </code></pre>
  
  <p>In the C# project I added a reference to the C++/CLI project (using right click > Add Reference).  During build I got an error in the C# project: "The type or namespace 'C_Wrappers' could not be found (are you missing a using directive or an assembly reference?)."</p>
  
  <p>I thought I did everything I was supposed to.  What should I do to fix this error?</p>