Renaming ICSharpCode.SharpZipLib.dll
Asked Answered
P

3

1

well I am having a problem renaming the ICSharpCode.SharpZipLib.dll file to anythig else. I am trying to shorten the file name. I reference the assembly in the project, but when the program reaches the statements where I use the library. It spawns an error that it could not find the assembly or file 'ICSharpCode.SharpZipLib'. When I change the file name back to ICSharpCode.SharpZipLib.dll the application works noramally. So, is there any way to change the file name. Also, am I allowed to change it without violating the license (I am going to use it in a commercial application). Thanks.

Paiz answered 13/1, 2011 at 18:45 Comment(3)
Probably you are having a reference in your application that still references the name before you renamed the assembly?Figge
Just curious on what exactly is the issue with the name length?Anthropomorphize
In computing, names are only just becoming descriptive, we're leaving a lot of terrible mistakes behind; Here's hoping you're not creating a time machine, to take us back there.Dentelle
I
7

You could try to disassemble the library and then re-assemble with a new name.

E.g.

1) Open Visual Studio command prompt.

ildasm /all /out=ICSharpCode.SharpZipLib.il ICSharpCode.SharpZipLib.dll
ilasm /dll /out=shortname.dll ICSharpCode.SharpZipLib.il

2) Add shortname.dll to the project

Inesinescapable answered 13/2, 2014 at 12:10 Comment(4)
I also had to edit the intermediate (.il) file and find/replace the old name with the new name. The replacements occurred in the ".assembly" and ".module" entries, specifically. This is definitely the easiest way to rename an assembly. Thanks.Selfpossession
This is great, but it doesn't work when there is unmanaged code.Coel
@Inesinescapable I tried de-assembling and re-assembling to short name using this, but I get an error during one step imgur.com/kZxtBZY . Any insights?Cullin
so i removed the code from .il which was giving error since I didn't need to s=thise functions , but now it gives me this error that : Could not create output file, error code=0x80070005Cullin
F
5

SInce you renamed the DLL, the .Net runtime doesn't know how to find it automatically.

You can call Assembly.Load to manually load the renamed file.
Note that you'll need to do that before calling any methods that use the assembly, since the JITter needs to load all types used (directly) by a method before the method starts executing.

Feminine answered 13/1, 2011 at 18:48 Comment(3)
@John: You probably loaded it too late. Load it before calling any methods that use it, so that the JITter can find it.Feminine
Slaks, that is what I did exactly (I have loaded the assembly on the form load event). I have spent about 6 hours looking for an answer, but what I should have done is dig into the documentation. After spending about half an hour reading on how the assembly resolution is done, I have figured out how it should be handled. Thanks a lot for your time.Paiz
You can listen to the AppDomain.AssemblyResolve Event which is raised when the JITer fails to load an assembly. In your event handler you can manually load the required assembly in the manner SLaks suggests.Bullbat
K
-2

The DLL is compiled so renaming the file will not change the namespace's inside of it anyway. You can assign an alias to it through a using directive.

using zip = ICSharpCode.SharpZipLib;
Kamala answered 13/1, 2011 at 18:49 Comment(2)
He's trying to shorten the file name.Feminine
Yes, I want to shorten the file name.Paiz

© 2022 - 2024 — McMap. All rights reserved.