Say, that we have the following application structure.
- MyApp.Web, which is a .NET MVC app for .NET 4.7.2;
- MyApp.Web uses MyApp.DataProviderWrapper assembly;
- MyApp.DataProviderWrapper references assembly MyApp.DataProvider (which is included as a binary in MyApp.DataProviderWrapper's project files)
- MyApp.DataProvider does a P/Invoke to MyAppDataProcessor.dll, which is a native library and has its own native dependencies which obviously I have access to too.
The problem is, that after starting the web app I'm getting classic error:
Could not load file or assembly 'MyAppDataProcessor.dll' or one of its dependencies. The specified module could not be found.
Application is running on IIS Express and unfortunately attempts to find out where system searches for this DLL failed, I'm getting no results there.
The obvious, but dirty solution is to put DLLs somewhere and include that somewhere to system PATH. I'm searching for a better solution either to:
- Configure project in such way that it will know where to seek for native librares, or
- Put the libraries in some folder in the project that they will be found when loading the MyApp.DataProvider assembly.
Is one of the solutions possible? How to approach using native libraries in .NET MVC projects?
Update: I do have DLLs in bin folder. But for some reason, one of assemblies is pushed to the following folder during run:
C:\Users\spook\AppData\Local\Temp\Temporary ASP.NET Files\vs\331a8458\b4c79531\assembly\dl3\0ae2569e\f3fde60f_7643d401
Since it's the only file in this folder, system cannot reach its dependencies, which are in bin folder and thus the failure. So the question is: why this file lands in the Temporary ASP.NET Files
instead of being loaded from bin folder?