title: Marshal.GetDelegateForFunctionPointer fails
body: <p>I'm trying to call an C function from a .NET application. Indeed I do the following:</p>
  
  <pre><code>public unsafe class Simd
  {
      [UnmanagedFunctionPointer(CallingConvention.Winapi)]
      public delegate void MatrixMultiplyDelegate(float* left, float* right);
  
      public static MatrixMultiplyDelegate MatrixMultiply;
  
      public static void LoadSimdExtensions()
      {
          string assemblyPath = "Derm.Simd.dll";
  
                    // Really calls 'LoadLibrary', 'GetProcAddress', 'FreeLibrary' from Kernel32.dll
          IntPtr address = GetProcAddress.GetAddress(assemblyPath, "Matrix4x4_Multiply_SSE");
  
          if (address != IntPtr.Zero) {
              MatrixMultiply = (MatrixMultiplyDelegate)Marshal.GetDelegateForFunctionPointer(address, typeof(MatrixMultiplyDelegate));
          }
      }
  }
  </code></pre>
  
  <p>The function loaded is declared as follow:</p>
  
  <pre><code>extern "C" {
  
      void __declspec(dllexport) Matrix4x4_Multiply_SSE(float *left, float *right);
  
  }
  </code></pre>
  
  <p>Sadly, I get the following exception when calling <em>GetDelegateForFunctionPointer</em>:</p>
  
  <blockquote>
    <p>InvalidFunctionPointerInDelegate:</p>
    
    <p>Invalid function pointer 0xb81005 was passed into the runtime to be
    converted to a delegate.</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>