title: Unable to use functions with pointer arguments from Visual C++ DLL in VB.NET
body: <p>I am trying to use a Visual C++ dll in a VB.NET windows application, both created in VS2010. In the Windows project I can successfully add the dll to my references but only functions without pointer arguments are usable in the program and visible in the object browser. I borrowed a simple example I found and changed one of the function arguments to be a pointer.
  header file:</p>
  
  <pre><code>// TestDLL.h
  
  using namespace System;
  namespace MathFuncs
  {
      public ref class MyMathFuncs
      {
          public: 
              static double Add(double *a, double B);
              static double Subtract(double a, double B);
              static double Multiply(double a, double B);
              static double Divide(double a, double B);
      };
  }
  </code></pre>
  
  <p>cpp file </p>
  
  <pre><code>// TestDLL.cpp
  // compile with: /clr /LD
  
  #include "TestDLL.h"
  
  namespace MathFuncs
  {
      double MyMathFuncs::Add(double *a, double B)
      {
          return *a + b;
      }
  
      double MyMathFuncs::Subtract(double a, double B)
      {
          return a - b;
      }
  
      double MyMathFuncs::Multiply(double a, double B)
      {
          return a * b;
      }
  
      double MyMathFuncs::Divide(double a, double B)
      {
          if (b == 0)
          {
              throw gcnew DivideByZeroException("b cannot be zero!");
          }
  
          return a / b;
      }
  }
  </code></pre>
  
  <p>The dll compiles successfully with no warnings. When I reference the dll in a simple windows form I get the error:</p>
  
  <p>"Error 1 'Add' has a return type that is not supported or parameter types that are not supported." </p>
  
  <p>If I remove the pointer the dll works fine. From other forums I thought the calling convention might be a problem and tried using <strong>__stdcall</strong> but I got another error saying reference classes can't use <strong>__stdcall</strong>. </p>
  
  <p>I also tried not referencing the dll and instead declaring the dll functions from a module in the windows application. I got an error saying "entry point not found" which I think is because C++ decorates the function name. I tried <strong>dumpbin.exe/EXPORTS "<em>dll PATH</em>"</strong>  but it would not show the decorated function names. I have also tried creating an module definition file and using extern "c" although I most likely didn't use them properly. All solutions I have found to these problems have been for unmanaged C++ but do not work for managed Visual C++.</p>
  
  <p>I would rather be able to reference the dll because it seems simpler. Any insight would be greatly appreciated. </p>