Renaming ICSharpCode.SharpZipLib.dll

人走茶凉 提交于 2019-12-23 02:55:17

问题


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.


回答1:


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




回答2:


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.




回答3:


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;


来源:https://stackoverflow.com/questions/4683913/renaming-icsharpcode-sharpziplib-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!