VB.NET web application path issue

Cerebus451

Golden Member
Nov 30, 2000
1,425
0
76
Hopefully I can describe this correctly. I have a thin VB.NET web application that is basically just implementing a SOAP service around another .NET manage DLL built in C++. The problem is the managed .NET library has a dependency on a third party DLL that is unmanaged code.

When I try to test the web site/SOAP service, I get an error that the managed DLL (or one of its dependencies) cannot be loaded. I put the unmanaged DLL in the same folder as the managed DLL (which works for a normal VB app), but still no dice. If I drop the unmanaged DLL into c:\windows\system32, it all works, but this is something that will get delivered to clients, so that is not a workable solution.

I once read somewhere that there were issues with putting the unmanaged DLLs in the same folder as the managed DLL, and that all you had to do was move the unmanaged DLL to another folder and figure out some way to modify the path. My Google-fu only reveals solutions that involve either copying the DLL to the system directory or modifying the system path on the machine, neither of which is a workable solution. I can't find any information on modifying the DLL search path for a web application and figured I would post here in the hopes that some other poor soul has run into this and knows the solution.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
13
81
www.markbetz.net
It's probably just that the version of the C/++ runtimes that the native DLL uses isn't present on your system. We ran into this just the other day, in almost the exact same circumstances. The native team had built their DLL with the 10.0 version of the MSVC runtime and the only ones of us who had it were those who installed C++ when they installed VS2010.

Use depends.exe to find out what libraries the native DLL requires, and make sure they are all present on your system and on the path when LoadLibrary is called.

Edit: missed the point that it works in system32. That's pretty strange, but anyway, I think depends.exe is still your best bet.
 
Last edited:

KB

Diamond Member
Nov 8, 1999
5,401
386
126
"If I drop the unmanaged DLL into cwindows\system32, it all works, but this is something that will get delivered to clients, so that is not a workable solution."

Why are none of these workable solutions? Because the client doesn't want you to do them? Or because you aren't building an install package to deliver the files?
Obviously an install pacage could easily do these steps; however, both of them can also be automated in the app to the point where the client wouldn't even know you were doing them.

You can change the user or processes (not the machines) PATH variable using:

System.Environment.SetEnvironmentVariable("PATH", Yourpathhere, EnvironmentVariableTarget.Process)

use EnvironmentVariableTarget.User for user

you could possibly put the code in the global.asax files on application startup.

You could also try to copy the dll to system32 on application startup, again in global.asax. For these in-app changes you may need to lazy load the managed dll so it doesn't attempt to load the unmanaged ddl on startup.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |