edit1: programming environment visual studio 2013.
i'm attempting call third-party dll (no source or header) using either c++ or c#. dll provider ships dll excel workbook, calls dll in vba, license manager dll called dllmain (i'm guessing, since license manager loaded when main dll loaded). in stock configuration, works expected. however, when attempt load dll in c++ (shown below), loadlibrary hangs in both debug , release mode:
#include <stdio.h> #include <windows.h> #include <string.h> #include <tchar.h> typedef int(_cdecl *myproc)(lpwstr); int main() { hinstance mydll; char dlldir[100] = "c:\\directory\\"; setdlldirectorya(dlldir); setcurrentdirectorya(dlldir); mydll = loadlibrary(text("c:\\directory\\thirdparty.dll")); // other stuff... } ...which frustrating in itself. however, mystery comes when tried same thing in c#:
namespace mydlldemo { class mydll { [dllimport("c:\\directory\\thirdparty.dll")] public static extern int simplefunction(); } class program { static void main(string[] args) { environment.currentdirectory = "c:\\directory\\"; int simplefunctionoutput; simplefunctionoutput = mydll.simplefunction(); ///other code... } } this code hangs @ call mydll.simplefunction, in release configuration! in debug configuration, function call successful. changing configuration settings, i've determined function call successful when visual studio hosting process enabled; disabling in debug configuration causes program hang @ function call. however, enabling visual studio hosting process in release configuration not prevent hang.
has encountered similar problem when loading dlls? weird piece of evidence familiar labview dll loads when called labview... in advance!
edit2: behavior observed c# holds true visual basic, well:
declare function simplefunction lib "thirdparty.dll" () integer sub main() chdir("c:\\directory\\") dim simplefunctionoutput integer simplefunctionoutput = simplefunction() end sub
Comments
Post a Comment