Say, that we have the following application structure.
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:
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?
The problem was shadow copy mechanism. It caused the assembly, which had native dependencies to be copied to Temporary ASP.Net files folder - thus separating it from required binaries, which were in the bin folder.
I found solution here: http://faithlife.codes/blog/2013/05/using-native-dlls-from-asp-net-apps/ . In a nutshell, add the following to the web.config to disable shadow copy mechanism:
<configuration>
<system.web>
<hostingEnvironment shadowCopyBinAssemblies="false" />
The other solution is to add folder with binaries to system PATH, but that was something I wanted to avoid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With