I'm writing a C++ application using Visual Studio Express 2013. My application makes calls to a module called refprop.dll. However, the call to SETUPdll fails sometimes (about half the time). Other times it works perfectly. My code is like so.

in refprop1.h

```
typedef  void(__stdcall *fp_SETUPdllTYPE)(long &, char*, char*, char*, long &, char*, long, long, long, long);
fp_SETUPdllTYPE SETUPdll;

```

in Main .cpp

```
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include "refprop1.h"

// Some constants...

const long refpropcharlength = 255;
const long filepathlength = 255;
const long lengthofreference = 3;
const long errormessagelength = 255;
const long numparams = 72;
const long maxcoefs = 50;

int main(int argc, char* argv[])
{

    // First create a pointer to an instance of the library
    // Then have windows load the library.
    HINSTANCE RefpropdllInstance;
    RefpropdllInstance = LoadLibrary("C:\\Program Files (x86)\\REFPROP\\REFPROP.DLL");
    //point the function
    SETUPdll = (fp_SETUPdllTYPE)GetProcAddress(RefpropdllInstance, "SETUPdll");

    //setup variables
    long i, ierr;
    char hf[refpropcharlength*ncmax], hrf[lengthofreference + 1],
    herr[errormessagelength + 1], hfmix[refpropcharlength + 1];

    i = 3;
    strcpy_s(hf, "D:\\East101\\Adri\\devprojects\\theSeed\\RefProp\\fluids\\METHANE.FLD|ETHANE.FLD|BENZENE.FLD");
    strcpy_s(hfmix, "D:\\East101\\Adri\\devprojects\\theSeed\\RefProp\\fluids\\HMX.BNC");
    strcpy_s(hrf, "DEF");
    strcpy_s(herr, "Ok");

   //call the setup - this SOMETIMES throws an error: Unhandled exception.....
   SETUPdll(i, hf, hfmix, hrf, ierr, herr, refpropcharlength*ncmax, refpropcharlength,lengthofreference, errormessagelength);

```

Edit:
I've also noticed that the problem only occurs for the SETUPdll call. The other calls can be made successfully (but meaningless because you need to call SETUPdll first). 

Also is there any way to debug the dll itself/peer into what's going on in there?