How to solve “Could not load file or assembly”

It’s one of the common error .net web developer come across “Could not load file or assembly’AssemblyName, Version=versionumber, Culture=neutral, PublicKeyToken=tokennumber’ or one of its dependencies.“.

 

I found the following steps should resolve in most cases

  1. Open ILDASM.exe at “C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\ildasm.exe”
  2. Open the the assembly file which is causing the error through ILDASM as followsildasm file open
  3. Get the Assembly version from the ILDASM after you open the file as shown belowildasm file open
  4. Use the version number and replace web.config at dependentassembly element, newversion attribute as shown below. Don’t forget to change oldVersion to higher number to cover the range.ildasm file open
  5. Also at Compilation>assemblies element version filedildasm file open

What is the Problem:

configured version and assembly version in bin folders are not matching

Okay, what we did:

By making above config changes we are telling to framework/current application use this particular version of assembly.

Points to Note:

  • Don’t use file version from file explorer, they are not accurate.
  • Dont forget to change oldVersion range

Leave a comment