c++ - DllNotFoundException From C# but not VB.NET -
i have 3rd party dll integrate application. 32 bit c++ dll not expose via com, , have not been supplied source code or header file.
it supplied working vb.net illustration code in winforms example. works, long executable run same directory api dll , application api interfacing.
i using illustration function declaration:
declare ansi function getversion lib "thirdpartyapi.dll" () integer
however, we’ll using api calls c# library used in web site or web service, converted illustration vb code to
[dllimport("thirdpartyapi.dll", setlasterror = true, charset = charset.ansi)] public static extern int getversion();
if phone call within c# library error
unhandled exception: system.dllnotfoundexception: unable load dll 'thirdpartyapi.dll': dynamic link library (dll) initialization routine failed. (exception hresult: 0x8007045a)
i took alternative route , set original working vb code illustration own vb.net dll , called via c#. got same error. strangely, phone call vb.net dll vb.net console app works.
in summary:
a simple vb.net console app work a simple vb.net winforms app work a simple vb.net console app can phone call getversion via vb.net dll a simple c# console app cannot phone call getversion via vb.net dll a simple c# console app cannot phone call getversion directly. incorrectly defining function calls. @ stage, i’m not worried this. 32 bit compilation not prepare issue i have tried on server 2008 r2 , windows 7 enterprisei created wcf host via nt service expose functions, hoping work around file locations , dependencies. written in vb.net , placed in same folder thirdpartyapi.dll.
none of code in nt service access getversion none of code in wcf service access getversionplease note, in of above cases, executables in same directory thirdpartyapi.dll. of dependencies exist in directory.
can explain behaviour, or suggest how can made work within c# web site?
thanks
the error code 0x8007045a
. com error code maps win32 error code error_dll_init_failed
. described as:
a dynamic link library (dll) initialization routine failed.
what means dll found, in spite of perhaps misleading exception class dllnotfoundexception
. however, dll failed load. can gain no more info system. there no mechanism dll study reasons why failed load. suggest contact vendor of dll , inquire support.
c# c++ vb.net pinvoke dllnotfoundexception
No comments:
Post a Comment