Question

I made a change to an ancillary DLL that my project uses, built it of course, renamed the legacy DLL to *.dll_old, and copy and pasted in the new version of the DLL to that same folder.

However, when I then ran the app that uses the DLL, it errored out with:

"An expected error has occurred...bla bla bla...or select Details for more information.

I did select Details, and saw:

TypeLoadException
File or assembly name <name of the DLL, which I just replaced>
Version=<bla>
Culture=neutral
PublicKeyToken=null, or one of its dependencies, was not found.

UPDATE

Based on the comments, I guess there's more to replacing a DLL than one might expect. I don't know if this is significant or not, I thought replacing a DLL would be like replacing an EXE, but maybe not: the DLL project's AssemblyInfo.cs says,

[assembly: AssemblyVersion("1.3.*")]                // used by .NET framework only
[assembly: AssemblyFileVersion("1.3.0.308")]        // File Version - increment here
[assembly: AssemblyInformationalVersion("6.3.0")]   // Product version - set to current IEQ system

...and the Version in the err msg is "1.3.3889.27539"

Do I need to update one of these lines (I would guess the middle one, if so) to that value (1.3.3889.27539)? Or...???

UPDATE

So since the .DLL is not strongly named, I tried simply removing the reference (to the old .DLL) in the project that uses the DLL and then adding it back again (same file name, different version). I see, though, that updating the .DLL does not change the version numbers shown above - IOW, the AssemblyInfo.cs does not get updated when building. Should it? Do I need to manually update these vals?

Was it helpful?

Solution

It seems that types inside your original DLL were referenced by your EXE file. WHen you replaced it with your own version the references were messed. The EXE file contains metadata table with a list of types, methods, properties, etc that it references and exact version of the assemble expected. Providing something else even if everything was the same but the version number is simply not the same thing. That is why you are getting the exception.

UPDATE: Yes it is possible. However it involves creating a manifest file. For more information check this MSDN web site on Redirecting Assembly Versions. Also, keep in mind that only strongly signed assemblies can be redirected. Non-signed assemblies will be ignored.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top