I have a .net 3.5 application with many dlls, I tried to rebuild specific dll without building the whole application, but after replacing the old one with the new, the application throws exception as it could not load the new dll exception: System.IO.FileLoadException: Could not load file or assembly .... I understand it searches for assembly with specific version and public token, how can I solve this problem without building the application again? also the application is signed but not registered in GAC. P.S: How can I skip building the app again, or it is a must as the dll is rebuilt?
The reason you get the error is because your assembly is signed, and most likely your reference to it has the Specific Version property set to True, and your version number of the assembly you made the change to has changed. I tried many scenarios, and this was the only scenario I was able to get the FileLoadException. If you had changed the Target Framework to a newer version like 4.0, you would get a BadImageFormatException instead. Even if you say you didn't change the version number, check it anyway, or set Specific Version to False by selecting your reference, and right clicking and selecting properties.
Your exception likely looked like this:
Could not load file or assembly 'LoadedAssembly, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=889080b75eb3bad2' or one of its dependencies. The located assembly's manifest
definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
But your compiled version if the assembly that is being referenced is no longer 1.0.0.0 (or whatever version, for example). In the image below (beit small), you can see that the reference property is looking for version 1.0.0.0, Specific Version is set to True, and the reference assembly is signed and is actually version 2.0.0.0, thus resulting in FileLoadException.
Resolve this by changing the version number back and recompiling, or setting Specific Version to False and rebuilding only that DLL. You do not have to rebuild your entire application.