title: "Unable to find an entry point named [function] in dll" (c++ to c# type conversion)
body: <p>I have a dll which comes from a third party, which was written in C++.
  Here is some information that comes from the dll documentation:</p>
  
  <pre><code>//start documentation
  
  RECO_DATA{
  wchar_t Surname[200];
  wchar_t Firstname[200];
  }
  </code></pre>
  
  <p>Description:
  Data structure for receiving the function result. All function result will be
  stored as Unicode (UTF-8).</p>
  
  <p>Method:</p>
  
  <pre><code>bool recoCHN_P_Name(char *imgPath,RECO_DATA *o_data);
  </code></pre>
  
  <p>Input:</p>
  
  <pre><code>char * imgPath
  </code></pre>
  
  <p>the full path of the image location for this
              function to recognize</p>
  
  <pre><code>RECO_DATA * o_data
  </code></pre>
  
  <p>data object for receiving the function
              result.
      Function return:
          True if Success, otherwise false will return.</p>
  
  <pre><code>//end documentation
  </code></pre>
  
  <p>I am trying to call the recoCHN_P_Name from my C# application. To this end, I came up with this code:</p>
  
  <p>The code to import the dll:</p>
  
  <pre><code>    public class cnOCRsdk
  {
      [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
      public struct RECO_DATA{
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst=200)]
          public string FirstName;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 200)]
          public string Surname;
          }
  
      [DllImport(@"cnOCRsdk.dll", EntryPoint="recoCHN_P_Name")]
      public static extern bool recoCHN_P_Name(byte[] imgPath, RECO_DATA o_data);
  }
  </code></pre>
  
  <p>The code to call the function:</p>
  
  <pre><code>            cnOCRsdk.RECO_DATA recoData = new cnOCRsdk.RECO_DATA();
  
          string path = @"C:\WINDOWS\twain_32\twainrgb.bmp";
  
          System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
          byte[] bytes = encoding.GetBytes(path);
  
          bool res = cnOCRsdk.recoCHN_P_Name(bytes, recoData);
  </code></pre>
  
  <p>And the error I'm getting is
  ""Unable to find an entry point named 'recoCHN_P_Name' in DLL 'cnOCRsdk.dll'."
  I'm suspecting that I'm having an error in converting a type from C++ to C#. But where exactly ... ?</p>