title: passing structure from c# to C dll
body: <p>I am trying to learn enough C# so that I can pass a strcture by reference to a C DLL; but it never gets to the "cFunction".  As you can see in the cFunction, I am explicitly setting the streamSubset value to 44; but back in the c# portion it does not return "44".
  Here is the C code:</p>
  
  <pre><code>typedef struct s_mPlot
  {
      double      price[100];
      int         streamSubset;
  } mPlot;
  
  extern "C" __declspec( dllexport )  
  void cFunction(mPlot *Mplot){
      Mplot-&gt;streamSubset = 44;}
  </code></pre>
  
  <p>// and here is the c# code </p>
  
  <pre><code> using System;
      using Vibe.Function;
      using System.Runtime.InteropServices;
      [StructLayout(LayoutKind.Sequential)]
      public class MPLOT 
      {
          [MarshalAs(UnmanagedType.ByValArray, SizeConst = 100)]
          public double []    price;
          public int          streamSubset;
       } 
  
  namespace Vibe.Indicator{
  public class myIdx : IndicatorObject {
  
      [DllImport("C:\\Users\\joe\\mcDll.dll", CharSet = CharSet.Auto)]
      public static extern void cFunction(
      [In, MarshalAs(UnmanagedType.LPStruct)]  MPLOT  mPlot );
      public myIdx(object _ctx):base(_ctx){}
      private IPlotObject plot1;
  
      protected override void Create()
      {
          MPLOT mPlot         = new MPLOT();
          mPlot.streamSubset = 2; 
          cFunction(mPlot);
  
          if (mPlot.streamSubset == 44)
               go();  
      }
  
  }
  </code></pre>
  
  <p>}</p>