Reputation: 26612
I have a solution which consists, to put it simply, a Windows Forms Application project and a Class Library, both in C#. My library project was named OldName
. Thus the namespace was also OldName
and the generated file was OldName.dll
.
I wanted to change the name, so I went into Properties, and changed the Assembly Name from OldName
to NewName
.
Building now generates a NewName.dll
. However, the moment my application tries to access this dll, I get a System.Runtime.Serialization.SerializationException
(the dll contains my methods for binary-serializing some stuff): It claims that Unable to find assembly 'OldName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Procmon.exe confirms that it is looking for the old dll (NAME NOT FOUND
).
Now the strange thing is, if I copy the NewName.dll
and rename it to OldName.dll
, so that I have OldName.dll
and NewName.dll
, the problem persists. If I delete NewName.dll
and only leave OldName.dll
, the program crashes at launch with: System.IO.FileNotFoundException: Could not load file or assembly 'NewName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
This time, Procmon.exe reports that it failed a CreateFileMapping
operation on OldName.dll
because FILE LOCKED WITH ONLY READERS
, but it seems it gets the same thing on NewName.dll
.
Changing the Assembly Name back to OldName
fixes everything, but of course then the file name becomes OldName
and I don't want that.
I can't for the life of me figure out where else it references the old assembly name. What could I be missing?
SOLUTION: My program allows the user to create a file, and then save it to the disk using serialization with the methods in my dll. It also Allows loading the file. Being lazy, I had made a test file once, and kept reusing it. Turns out, as @Tigran suggested, the old Assembly name still appeared inside the serialized data file, so when I attempted to load it from my program I was getting an exception because it couldn't find the assembly referenced in the serialized file.
Upvotes: 3
Views: 3544
Reputation: 62296
I suppose that in your program you use standart .NET serialization
. Remember that in that kind of serialization .NET
saves type information too. Complete type information, with namespace. That means if you change assembly name and recompile the complete type name will get mismatch.
If this is not what you-re doing, please clarify.
Upvotes: 5