Unable to load DLLs when starting up IIS Express hosted web project (VS2015) - asp.net

Backgroud:
I am in the process of migrating a console application to be part of our existing web API project. All development work is done on Visual Studiod 2015 (with IIS Express). The application uses few third party datasource api DLLs to grab data from that datasource. All these DLLs are managed by our internal nuget package sources.
Issue:
Now the console application runs fine and can load up the those DLLs. I copied across the logic into my web project and added the DLLs via nuget. Solution builds but got the following error when starting up the web project:
Could not load file or assembly 'ABC.DLL' or one of its dependencies. The specified module could not be found.
Where ABC.DLL is one of the third party DLLs.
I have done the following:
Confirm ABC.DLL is in the bin folder of my web project
Changed target build platform of my web project to be x86 and unchecked "Use 64 bit version of IIS Express for websites and project" setting in VS2015 (the third party dll is 32-bit)
Ran dumpbin.exe on ABC.DLL's dependency and got XYZ.dll,MSVCR120.dll,KERNEL32.dll,MSVCP120.dll,mscoree.dll
Regarding to the last step, those dlls were all missing in the bin folder (but the last 4 DLLs should be in system32 win directory so shouldn't matter?)
As for XYZ.dll, it is another third party library and is located on C:\Program Files (x86)\XYZ\ folder. I manually copied it across to the web project bin folder (in fact copied across all Dlls inside XYZ folder) and still get the same issue.
Questions
What am I missing here? The console app obviously can load ABC.DLL but the web project can't. Appreciate it if you can tell me what to check next.
The error message from start up web page is not very useful, is there a way to find out where the web project is trying to load the third party DLLs?
Thank you in advance!

Simply adding external DLLs to your Bin folder is not a great idea. Files can disappear from this folder for various reasons, such as your team members deleting a seemingly useless DLL, or through Visual Studio clearing it. Also, the output DLLs from referenced projects in your solution, would end up there, and are replaced every time you build your project.
What you should do for third-party DLLs, is create some "dependencies" folder in, or close to, your project, and stick the DLLs in there. Then you should right-click on the project, select Add Reference, browse to that new "dependencies" folder, and add a reference to the DLL that way. This is similar to the way NuGet works; it keeps DLLs in their respective folders inside the packages folder, and adds references to those DLLs.

I finally found the issue and thanks for all the help, I had to disable shadow copying in VS (mentioned in 64 bit managed assembly with unmanaged dependencies not loading in IIS / ASP.NET MVC 4).

Related

Visual Studio 2017 won't compile my ASP.NET web project, saying "could not load file or assembly" for a library that is definitely being referenced

Current Situation:
I have an ASP.NET web project. (Framework Version: .NET Framework 4.5.2)
One developer here is able to compile it and run it fine in Visual Studio 2017.
I cannot, I get the "could not load file or assembly" error for a reference that is in my list of references.
Screenshots:
Error:
Bin Folder:
Web.config Potential Relevant Sections:
DevExpress Licenses File:
DevExpress Library File's Details:
Things I've Tried:
Clean Solution & Rebuild Solution
Deleted solution locally and clean get of solution from source control
Clearing out my temp directory
Opening the project in Visual Studio 2015
Having the developer zip up his local copy of the solution / project and sending it to me (When I ran his copy locally I continued to get the same error.)
Re-adding the existing library it's complaining about
Manually deleting and re-adding all the libraries in my BIN folder
Messing with the license file, web.config, and assembly references in code (including adjusting the version numbers because for some reason the version number is 17.2.5.0 anywhere it's referenced in the project, but the file's Details actually says it's 17.2.9.0?)
Smashing my face into my keyboard...
...Always the same error.
Additional Information
Other developers run into the same exact error under the same conditions as me, only my one developer who's been working in this project can build it fine
I just noticed that on a new copy of the work project, my references window is showing 2 of the same reference to the DevExpress.Data library (one in the GAC and one in the BIN) but when I try re-adding the reference to my project, the one in the BIN disappears from my references window:

Why are c++ .dll not recognized in bin folder of asp.net webapp?

I create an ASP.NET Webapp with Razor syntax in Visual Studio 2015, in C#.
I have to use 20 third party native c++ dll files (most of them for image handing, libtiff-5.dll, libpng16-16.dll, etc...).
Even when I manually copy those dll files into the bin folder, the app would not run. The error is:
Could not load file or assembly 'managedDllWrapper.DLL' or one of its dependencies. The specified module could not be found.
But according to almost all hints in the internet, copying to bin folder should work.
When I copy the dlls into the C:\Windows folder, the webapp runs perfectly, but only locally on my machine.
Also, when I create a C# Console app, instead of a webapp, copying into the bin folder works fine.
Why doesn't it work for a webapp? How can I import those dlls?
I cannot reference them into Visual Studio to the project, as they are not a valid COM assembly.
the dlls are not imported in the code with dllimport, as I don't know the specific functions they provide. A managed dll wrapper uses the dlls.
Any ideas? Thanks!
I did not solve the problem one to one, but I circumvented the problem successfully:
By rewriting the c#/c++ wrapper with explicit dllimport, I adressed the dll files directly with path. Then, the dependent dll just have to be in the same folder as the referenced dll. This works also in web apps.

How to deploy ASP.NET MVC application with devexpress components to Azure websites

Is there a way to deploy asp net application with dexexpress components other than using virtual machine with installed libs on it?
I want to deploy it to azure websites but get an error that .dll are missing (dont get that error during debugging on localhost where devexpress installed).
Be sure, that you marked the referenced assemblies that you want to publish on the vm as "copy local = true". You can find that option in the properties of a reference.
The output folder of your web app will be automatically copied over to azure websites. For more information how web pages are packaged have a look How to: Create a Web Deployment Package in Visual Studio
You can try one of these options:
Find a NuGet package which includes the dll's you need. I don't know which components you use but NuGet contains a lot of packages -> https://www.nuget.org/packages?q=devexpress
Include the dll's you need in a 3thPartyLib in your project and then reference these assemblies (with copy local = true) from your project.
Be sure to include the license file in your deployment.

Where does ASP.NET look for binaries when you compile an ASP.NET 4 web project under x86 (32-bit)?

I'm developing an ASP.NET MVC 4/Web Api application in VS 2010 on my 64-bit dev machine. I have IIS installed and am running the project under IIS. Because I need to interface with a third party component, I have to change the project build configuration to x86 (I'm currently in the Debug build).
In IIS, I configured the application to use an application pool that allows 32-bit processes. However, when I ran my site, I noticed that code changes I was making were not showing. It turns out that the assemblies being used were those found in the \bin folder. After changing the configuration, the compiler's assembly output goes to the \bin\x86\debug folder; it didn't look like IIS was looking there.
I temporarily switched the configuration back to "Any CPU", right-clicked the project node, and selected the Clean option. This removed all the stale assemblies in the \bin folder. I then switched back to the x86 configuration -- rebuilt the project for good measure -- and tried to run the project again. Now it wasn't finding any assemblies at all. I'm getting errors like:
Could not load file or assembly 'System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies
System.Web.Providers -- and all the rest of the assemblies -- reside in \bin\x86\debug.
Is IIS supposed to know to look there?
Is Visual Studio supposed to copy the assemblies up two levels to the \bin folder?
If the latter, that is clearly not happening. Thanks for any insight.
The solution was simply to set the Output Path to bin in the Build tab of the project properties. :-)

How to correctly deploy Oracle.DataAccess.dll with ASP.NET app

We had some x64 / x86 trouble when we first deployed the Oracle.DataAccess.dll with our app on different servers with 64/32 bit Windows. Now that we figured out how we can get the app to reference the correct version, I still have trouble with a .dll file that is getting in the way during deployment.
Situation is as follows: I have one project in my solution that references Oracle.DataAccess. I set the "copy local" property to False, because on the server, I would like the app to use the .dll from the GAC or another folder (which would be the 64bit version instead of 32bit on development machine). The dll is not added to the project bin output folder, but it is copied to the web-app bin folder. When I deploy to our test-server, it uses the dll from the bin folder instead of the dll from the Oracle installation folder on the server (i.e. c:\oracle\odp.net\bin\4)
What can I do to NOT have the dll in the bin folder?
Keep in mind it only uses the dll for the reference. When the code actually calls the functions inside to connect to Oracle - .net uses the provider classes to get the usage (interface) for the Oracle client from the oracle installation directory.
That being said - in our applications - we just deploy the correct version in the bin folder based on the bit level of the OS. We have to do this since our apps support both Oracle and Sql - and the references would break for our Sql clients if the dll was not there.
One cause of this problem that we have found is when your web project does not directly reference Oracle.DataAccess.dll, but does reference another project that references it. This happens even when Copy Local is false on the referenced project.
The solution we found to work is to add the reference directly to your web project, and then set its reference to Copy Local to false.

Resources