c++ - Access violation reading location when accessing a dll method -


i using following code access method in dll file , getting access violation reading location 0x41100000 when calling method dll method.

the method trying access of following prototype

 int dstoch(float,float,float,float,float,float,float,float,float); 

this code

typedef int (*lpmyfunct)(float,float,float,float,float,float,float,float,float); hinstance hdll = null; lpmyfunct lpdstoch = null;  hdll = loadlibrary("c:\\myfile.dll");  if(hdll!=null) {     std::cout << "library loaded \n";     lpdstoch = (lpmyfunct)getprocaddress((hmodule)hdll, "dstoch");      int res = 0;     if(lpdstoch != null)     {         try         {             res = lpdstoch(1.1,2.2,3.3,4.4,5.4,6.4,7.4,8.8,9.9); //gives error         }         catch (std::exception &e)         {             std::cout << e.what();         }        } } 

any suggestions reasons ? chance there error in dll file ? there way read parameters of dll file ? disect check if getting parameter types correct ? decpendency checker shows method exists cant acertain argument types ?

update:

i still getting error

first-chance exception @ 0x0040356c in test.exe: 0xc0000005: access violation writing location 0x42080000. unhandled exception @ 0x0040356c in cexperiment.exe: 0xc0000005: access violation writing location 0x42080000.

i believe issue might not related calling convention .the reason believe because not error message vs2010 stating calling convention may cause.i got message when tried using other dll. if calling convention or parameters not issue (you same calling convention message incase parameters different) might else. suggestions on try ?

you need check calling convention of dll function , declare lpmyfunct type accordingly. possible values calling conventions are: stdcall, cdecl, pascal.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -