user79284
user79284

Reputation: 175

Moved over to .NET 4.5. Getting ""Could not load file or assembly _____ or one of its dependencies." error

I just converted a 3.5 project in VS 2008 over to Framework 4.5. The web site has two projects (lets call the Business and Reports) referenced.

Everything works with the development webserver within VS 2012. But when I set it up on my local IIS*, I get the

"Could not load file or assembly 'Reports' or one of its dependencies. An attempt was made to load a program with an incorrect format.:

I see the dll for Reports in the bin directory. I played with the platform of the build to x86 and back to AnyCPU, but it still does not work.

(I did set the application pool's .NET framework version to 4.0.)

EDIT: Can anyone help me discipher the message below? I see HKEY_LOCAL_MACHINE\Software\Microsoft\Fusion. But what is "Fusion!EnableLog"? I don't see anything ike that.

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Upvotes: 2

Views: 1365

Answers (1)

Ciaran Gallagher
Ciaran Gallagher

Reputation: 4020

It could be possible that the DLL in question only works with a 32-bit (x86) build.

Rebuild your program, targeting the x86 build.

Then in IIS, right click on the Application Pool serving your application and click 'Advanced Settings'. From here, set the 'Enable 32-Bit Applications' value to 'True', then recycle the app pool and restart your website and let me know if you still get the error.

If you don't know which App Pool your website is using, click on your website under 'Sites', then select the 'Basic Settings' option on the Actions pane. From here you can see which application pool is serving your application, and if need be, you can change the app pool. App pools are managed from the 'Application Pools' option on the 'Connections' pane in IIS.

I think that if you are building from a 64-bit machine, then selecting 'Any CPU' may result in a 64-bit build, and so if the referenced DLL was built targeting x86, then this may be why you were getting an error message.

Upvotes: 1

Related Questions