Last post May 24, 2019 07:40 AM by kjporbis
May 21, 2019 06:14 AM|Surya2sunny|LINK
I am creating a WebApp using Asp.Net Core (2.2). From my web-app I am calling an exe. This exe (written in C++) internally calls LoadLibrary function to load an unmanaged dll. LoadLibrary call is failing in my case.
If i create a C# console app, then I am able to invoke LoadLibrary successfully.
Please suggest how to rectify this problem.
This is my webapp code where i am invoking the exe -
ProcessStartInfo sprbProcessInfo = new ProcessStartInfo();
sprbProcessInfo.FileName = @"C:\Program Files\SmartPlant\Interop Publisher\SPRB.exe";
sprbProcessInfo.Arguments = "\"" + strSrcFileFullPath + "\"" + " -b " + "\"" + strDestFileFullPath + "\"";
sprbProcessInfo.RedirectStandardOutput = true;
sprbProcessInfo.UseShellExecute = false;
Process oTranslateProcess = new Process();
oTranslateProcess.StartInfo = sprbProcessInfo;
This is what I am trying to do in my exe -
LoadLibrary (csSolidsFile); ===> this call is failing
May 21, 2019 09:33 AM|Xing Zou|LINK
Not familiar with C++, but .NET Core does not (yet) support C++/CLI and will fail to load such libraries. .NET core is cross platform but C++/CLI is not, the Microsoft C++ compiler requires Windows. Refer to this github
May 21, 2019 02:01 PM|bruce (sqlwork.com)|LINK
most likely the library is not found, you probably need to set the working folder to the location of the library.
May 22, 2019 04:51 AM|Surya2sunny|LINK
I am tying to create WebApp for existing desktop app which is written in C++. From my webapp I am trying to invoke the process. Inside the c++ exe it is trying to load some DLL which is failing in my case. Same thing is working fine when i directly invoke
the desktop app from cmd. When you suggest to set working folder to the location of library do u mean to copy all dlls to webapp's bin directory?
May 22, 2019 05:42 AM|Xing Zou|LINK
Hvae you tried to LoadLibrary with a full path. If the absolute path is passed when calling LoadLibrary, the loader will only try to search for the DLL from that absolute path.
Refer to https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-loadlibrarya#parameters
May 23, 2019 02:16 PM|bruce (sqlwork.com)|LINK
if you can run the desktop app from the command line from any folder, than you have another issue. If you can not, then in process create set the working folder to the folder containing the desktop app and its libraries.
Also, to run under asp.net, the desktop app should not use a profile or open any windows, as this will fail.
May 24, 2019 07:40 AM|kjporbis|LINK
This is most likely a permissions issue.
Your web app will most likely be running in a different security context therefore I would suggest checking that this context has access to the DLL you are trying to load.