9

I have created one tool using console application named "DocumentHashcode" in which I am using third party DLL - DocumentFormat.OpenXml.dll.

When I'm going to deploy it, I am using DocumentHashcode.exe and DocumentFormat.OpenXml.dll for running the application.

I want to rename DocumentFormat.OpenXml.dll to CATBldHashCodeSupporterDll.dll. Can anyone advise how to achieve this?

Steve Mayne
  • 22,285
  • 4
  • 49
  • 49
Alpa
  • 117
  • 2
  • 9
  • 1
    Why would you hide the fact that you use OpenXML? – alzaimar Jan 09 '13 at 07:11
  • 1
    Actually i made a tool, that is used by another client and they want to give their own naming conveniences, that's why. do you have any idea regarding that? – Alpa Jan 09 '13 at 07:21
  • 1
    You might find an answer here: http://stackoverflow.com/questions/4683913/renaming-icsharpcode-sharpziplib-dll – alzaimar Jan 09 '13 at 07:34
  • I have read it, but i m not finding anything helpful. – Alpa Jan 09 '13 at 08:34
  • Can anyone please suggest that how can i change the name of the third party dll? – Alpa Jan 11 '13 at 10:23
  • Well, the answer says, that you should not do it. But if you do so, you have to load the library manually as early as possible. Please, read the thread and understand. BTW: If you work at Google and drive a Mercedes, would you change the label on your car to 'Goocedes'? Just leave it as it is. Less problems, more fun. – alzaimar Jan 11 '13 at 18:40
  • that's right, but it's requirement, so i want to do that. – Alpa Jan 14 '13 at 12:35
  • Well then read the article and try to follow the instructions. – alzaimar Jan 15 '13 at 06:48
  • which article? can you plz share it... – Alpa Jan 16 '13 at 10:02
  • Please, look at my post from jan 9 7:34 above – alzaimar Jan 16 '13 at 18:15

3 Answers3

5

You need to manually load the assembly. The simplest way is to load it before the JITer tries to load the DocumentFormat.OpenXml namespace. You can manually load it like this:

var dllPath = Path.Combine(Directory.GetCurrentDirectory(), "reNamed.dll");
Assembly.LoadFile(dllPath);

Alternatively you could listen to the AppDomain.AssemblyResolve event, which gives you the chance to load the renamed DLL once the JITer has failed to find it.

David Pond
  • 1,095
  • 9
  • 15
1

You can also try to re-assemble the DLL file with a new name. For details, please check last answer in Stackoverflow: Renaming ICsharcode-dll.

Community
  • 1
  • 1
user797717
  • 758
  • 1
  • 6
  • 18
1

If you don't mind getting a bit dirty, you can use a text editor to alter your .csproj file. If your .dll, for example, is xr-CommInterop.dll you should find some XML like:

<Reference Include="xr-CommInterop, Version=3.0.0.0, Culture=neutral, processorArchitecture=AMD64">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>C:\Mypath\xr-CommInterop.dll</HintPath>
</Reference>

If you alter the first xr-CommInterop (in Reference Include="...) to just CommInterop and reload the project, you will find the reference now has a different name.

Jens Fiederer
  • 420
  • 4
  • 7
  • I was wanting to rename dll as well , hence did this but if I remove like xr and just use CommonInterlop , it for a second loads without xr and then renames automatically back to having xr. I guess beacuse inside the hint path its still has xr tho –  Jun 08 '21 at 01:37