Friday, March 13, 2015

ASP.NET : Could not load file or assembly

For example:

"Could not load file or assembly System.Web.Http.WebHost, Version=4.0.0.0".

Came to work one morning, built my system, WTF, error as above.

All worked perfectly when I left the day before.

There had been a Windows Update during the night and obviously some dll's had been updated - so much for backward compatibility.

Problem was - I couldn't figure out who was calling this dll and hence where the reference / binding was

Mr. Google and came across this Scott Hansleman post:

Back to Basics: Using Fusion Log Viewer to Debug Obscure Loader Errors

I'm using VS 2013 and Windows 8.1.

So go to:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts

This is the shortcut to the VS Command Line Tool - "Developer Command Prompt for VS2013".

In the command line - fuslogvw.exe - run as Administrator.

In Settings - "Log bind failures to disk" / "Enable custom log path". Type in path - make sure the path exists.

Restart IIS.

Navigate to your web site - get the error - back to the tool - click "Refresh" - BOOM.

You will also notice that the text on the ASP.NET error page is different - it doesn't talk about the regedit change.

To repeat - if you use the tool you don't have to screw around with registry settings.

When you are done, remember to disable the log via the tool as it slows everything down.

Enjoy!


No comments: