title: COM Interop usage (converting from C++ to C#/.NET)
body: <p>I have a few COM libraries (TISCOPELib and MIPPARAMLib) that I have been using in C++ (unmanaged) and now I'm converting to C#.</p>
  <p>This snippet of code works in C++:</p>
  <pre><code>TISCOPELib::IFilterBlockCasette *casette;
  ... inialization ...
  int position = casette-&gt;Position;
  ... other stuff ...
  </code></pre>
  <p>In C#, I would have to do one of the following:</p>
  <pre><code>TISCOPELib.IFilterBlockCasette casette = microscope.FilterBlockCasette1; // Init stuff.
  MIPPARAMLib.IMipParameter param = casette.Position;
  int position = param.RawValue;
  ... other stuff ...
  </code></pre>
  <p>Or</p>
  <pre><code>TISCOPELib.IFilterBlockCasette casette = microscope.FilterBlockCasette1; // Init stuff.
  int position = casette._Position;
  ... other stuff ...
  </code></pre>
  <p>If I did this:</p>
  <pre><code>TISCOPELib.IFilterBlockCasette casette = microscope.FilterBlockCasette1; // Init stuff.
  int position = casette.Position;
  ... other stuff ...
  </code></pre>
  <p>I would get the following error:</p>
  <blockquote>
  <p>An unhandled exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Anonymously Hosted DynamicMethods Assembly</p>
  <p>Additional information: Cannot implicitly convert type 'System.__ComObject' to 'int'</p>
  </blockquote>
  <p>The <code>System.__ComObject</code> in this case is supposed to be <code>IMipParameter</code> with <code>int</code> as the <code>RawValue</code> property.</p>
  <p>So what is the best course of action here? Use a IMipParameter intermediate step, use _Position, or is there another solution? If I used the IMipParameter, is there a way I can get static type checking?</p>