BadImageFormatException in IIS on x64

I am using Windows 7 x64. When starting an MVC application, I get a BadImageFormatException exception. If it runs in an application pool with 32-bit applications enabled, an exception is not thrown. Sounds like loading global.asax. I turned on the fusion logging registry setting (HKLM \ software \ Microsft \ Fusion! EnableLog). This is the log:

=== Pre-bind state information === LOG: User = NT AUTHORITY\SYSTEM LOG: Where-ref bind. Location = C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\spl.sim.mvc\5802065c\a2782d40\App_global.asax.olejmmua.dll LOG: Appbase = file:///C:/Spl/SimSvn4.5/Source/Spl.Sim.Mvc/ LOG: Initial PrivatePath = C:\Spl\SimSvn4.5\Source\Spl.Sim.Mvc\bin Calling assembly : (Unknown). === LOG: This bind starts in LoadFrom load context. WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). LOG: Using application configuration file: C:\Spl\SimSvn4.5\Source\Spl.Sim.Mvc\web.config LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/spl.sim.mvc/5802065c/a2782d40/App_global.asax.olejmmua.dll. ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated. 

Using various build configurations, this is the result:

Build x64, 32-bit application pool false: Error

Build x86, 32-bit application pool false: Error

Build AnyCPU, 32-bit application pool false: Error

X64 build, 32-bit application pool true: Error

Build x86, 32-bit application pool true: OK

Build AnyCPU, 32-bit application pool true: OK

IIS Express: OK

How to find the 32-bit DLL problem used in the 64-bit configuration?

+4
source share
1 answer

I found a problem. I used Instrumentation for profiling. This added the following lines to web.config:

 <dependentAssembly> <assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <codeBase version="11.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2011.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL" /> </dependentAssembly> 

After removing this dependent assembly from the web.config section, the program runs as expected. I also removed the assemblyPostProcessorType attribute from the compilation element

+6
source

Source: https://habr.com/ru/post/1443206/


All Articles