title: Access violation exception when using a DLL function
body: <p>I created a simple DLL as part of my C++ exercises, but I'm getting an access violation exception when invoking DLL function. Here is the DLL's header file(I doubt the CPP will be usefull here):</p>
  
  <pre><code>#pragma once
  
  namespace MathFuncs
  {
  class MyMathFuncs
  {
  public:
      // Returns a + b
      static __declspec(dllexport) double Add(double a, double b);
  
      // Returns a - b
      static __declspec(dllexport) double Subtract(double a, double b);
  
      // Returns a * b
      static __declspec(dllexport) double Multiply(double a, double b);
  
      // Returns a / b
      // Throws DivideByZeroException if b is 0
      static __declspec(dllexport) double Divide(double a, double b);
  };
  }
  </code></pre>
  
  <p>And here is my main:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "windows.h"
  
  using namespace std;
  
  int main(void)
  {
      double (__cdecl *MYPROC)(double,double);
      /* get handle to dll */
      HINSTANCE hGetProcIDDLL = LoadLibrary("DLLExample.dll"); 
  if(hGetProcIDDLL == NULL)
      throw;
     /* get pointer to the function in the dll*/
      FARPROC lpfnGetProcessID = GetProcAddress(hGetProcIDDLL,"Add"); 
      if(lpfnGetProcessID)
          throw;
      MYPROC = (double (__cdecl *)(double,double))lpfnGetProcessID;
      if(MYPROC)
          throw;
  
      double x = MYPROC(5.5,5);
  
      return 0;
  }
  </code></pre>
  
  <p>Any suggestions? Thanks!</p>