9
votes

I have a Web Forms Web Site project. This web site references 4 class library projects. 3 of these class libraries reference a third-party assembly. I am getting the following compiler error for each of the 3 class library projects.

ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'myAssembly' or one of its dependencies. An attempt was made to load a program with an incorrect format. [Project. metaproj]

I have tried all possible combinations of AnyCPU/x86/x64 on the class library projects. I cannot change this on the Web Site project. I have both a x86 and x64 version of the third-party dll. Tried both.

"ClassLibrary.csproj" (default target) (4) -> (ResolveAssemblyReferences target) -> C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1561,5 ): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "ThirdPartyDll, Version=xxx, Culture=neutral, processorArchitectu re=x86", "x86". This mismatch may cause runtime failures. Please consider chang ing the targeted processor architecture of your project through the Configurati on Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture th at matches the targeted processor architecture of your project. [ClassLibrary.cspro j]

The bellow illustrates the solution configuration. Note I cannot change from "AnyCPU" here, only from within each individual class library project.

Solution configuration

All .NET 4

Converting the Web Site to a Web Application is not an option.

Thanks,

2
See David Sacks answer here: stackoverflow.com/questions/10113532/…Tod Thomson

2 Answers

6
votes

Obviously, you have a native 32 bit DLL. So the application pool on IIS must be configured to run the .NET framework in 32 bit mode.

This can be configured in the IIS Manager. Go to "Application Pool", select the relevant application pool and open the "Advanced Settings..." dialog. The 32 bit option is close to the top.

0
votes

One of your referenced assemblies is x86 only and thus the project chain that references it must be build for x86 only. Make also sure that when you deploy your application pool is configured for 32bit.