Reputation: 1057
I am getting the famous error:
Could not load file or assembly 'Oracle.DataAccess', Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
For a ASP.NET MVC 5 application running on .NET 4.5.2.
The Oracle.DataAccess assembly is referenced by one of the references of my application:
Web Application -> My Class Library -> Oracle.DataAccess
In a previous MVC 3 application I have forced ASP.NET to ignore the reference using:
<system.web>
<compilation debug="true">
<assemblies>
<remove assembly="Oracle.DataAccess" />
</assemblies>
</compilation>
</system.web>
This project works on the exact same version of Visual Studio on the exact same version of the .NET runtime with the exact same Web.config section (any typos here are because I don't have the config available to look at at the moment). I have restarted / rebuilt, deleted bin and obj folders all to no avail.
Is there anything I am missing, has this <system.web>
section started being ignored in MVC 5?
Alternatively what can I try in terms of diagnostics? I am not sure FUSLOGVW would help diagnose the issue?
(I can't change to x64/x86 due to requirements).
Upvotes: 0
Views: 823
Reputation: 260
I had the same problem. I'm not entirely sure when the behavior changed but it appears the ASP.NET plumbing is scanning the bin directory and loading everything there regardless of the <remove assembly="blah"> entries. I solved the problem by leaving the <remove> and also preventing the offending assembly from being published by creating a Project_Name.wpp.targets file.
<!-- language: lang-xml -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ExcludeFromPackageFiles Include="bin\BAD_GUY_ASSEMBLY_NAME.dll">
<FromTarget>PROJECT_NAME_HERE.wpp.targets</FromTarget>
</ExcludeFromPackageFiles>
</ItemGroup>
</Project>
I followed the directions here: https://www.asp.net/web-forms/overview/deployment/advanced-enterprise-web-deployment/excluding-files-and-folders-from-deployment
----- Ed
Upvotes: 1