Rakesh Vemula Blog

Drive towards unknown

Could not load file or assembly Exception in Visual Studio

Scenario :

One of our project is developed in VS 2013 then deployed in two pre-prod servers. Later , one of the server API started throwing random exceptions. After reading few articles about the process of picking dll’s by CLR we came to know that VS picks dll’s by simple names not by their exact name and version. In our project one of the referenced dll is having a reference to system.web.http v4.0 and also has the referencing to 5.2 but still the CLR is picking the 4.0 version at run time. This issue can be seen only at runtime.

Root Cause :

Visual Studio picks referred dll’s using their simple names but not by the exact name and version.

  1. If the project is having reference to the same dll of two different versions.
  2. If the GAC is having a different version of the dll not similar to the version referenced by project then compiler will be confused on what to choose.

Solution :

The Issue is solved after removing web.http v4.0 from Object Browser dll’s list. So, we have to remove the duplicate dll’s from Object Browser .