Can I change a dll reference within a third-party dll?

horgh

I've got two third-party dlls, which both are not strongly-named. I wanted to reference these dlls in app.config to be able to locate them once on the network and avoid copying multiple times for each application using them...As far as I understand, to reference them via assemblyBinding in app.config file they should be strongly-named:

<runtime>
  <dependentAssembly>
    <assemblyIdentity name="External"  culture="neutral" publicKeyToken="xxxx"/>
    <codeBase version="1.0.0.0" href="FILE://N://Lib/External.dll"/>
  </dependentAssembly>
...

So I need to sign them. Thanks to .NET-fu: Signing an Unsigned Assembly (Without Delay Signing) I managed to sign them with my *.snk file:

ildasm /all /out=Bar.il Bar.dll
ilasm /dll /key=Foo.snk Bar.il

Then I replaced references in my solution to the signed ones and set CopyLocaly to false. Afterwards I edited the app.config file with the new publicKeyToken.

However when running my application I still get FileLoadException, saying that loader cannot find one of these dlls with publicKeyToken=null.

So I decided that one these dlls references the other, and that reference definetely does not know anything about the signed version of the other dll.

Here comes the question: is there a way to change the reference inside the first dll to the signed version of the second one? Or my only options would be not to use app.config for these dlls and load them manually in code with, say, Assembly.LoadFrom?

horgh

It appeared to be quite easy in the end. In the *.il file of the dll containing a reference to the second dll I found the following entry by the name of the second dll:

.assembly extern /*23000002*/ SecondDllName
{
  .ver 1:0:0:0
}

and I changed it to

.assembly extern /*23000002*/ SecondDllName
{
  .publickeytoken = (xx xx xx xx xx xx xx xx )  
  .ver 1:0:0:0
}

i.e. added the generated public key token.

Then I reassembled the dll with

ilasm /dll /key=Foo.snk Bar.il

And it worked.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can I change a dll reference within a third-party dll?

From Dev

Can I load a third-party .dll in R?

From Dev

How to reference and ship an external / third-party .NET DLL within a solution under version control at Visual Studio?

From Dev

How can I make my application find a third-party DLL using Visual Studio?

From Dev

Troubleshooting PInvokeStackImbalance with a third party DLL

From Dev

Capture Third Party DLL events in WCF

From Dev

Weird NullReferenceException in third party dll: C#

From Dev

CMake - install third party dll dependency

From Dev

I can not use the properties and variables of a library of classes within a dll

From Dev

How to make a third party plugin for Qt using another DLL?

From Dev

Using third party dll in Qt (No .lib file available)

From Dev

VSTO Outlook 2013 third party dll not being found

From Dev

How to make a third party plugin for Qt using another DLL?

From Dev

Using third party dll in Qt (No .lib file available)

From Dev

SharePoint 2010 Sand box solution does not work with third party DLL

From Dev

Create a wrapper around a third party dll to abstract the dll and to be able to unit test my code

From Dev

Compile Brotli into a DLL .NET can reference

From Dev

appharbor: thirdy party .dll and GAC referenced .dll

From Dev

appharbor: thirdy party .dll and GAC referenced .dll

From Dev

Can I write a class within an ASP.NET site without compiling a DLL?

From Dev

Ambiguous invocation of third party reference

From Dev

How can I find which projects reference a specific dll in my solution?

From Dev

How can I add a SWIG-generated C++ DLL reference to a C# project?

From Dev

How can I reference FakeLib.dll in a Fake.Deploy deployment script?

From Dev

How can I find which projects reference a specific dll in my solution?

From Dev

Using DirectX within a Dll

From Dev

How can I full parsing HTML without third party library?

From Dev

How can I use a third party Class Object as Hashmap Key?

From Dev

How can I contribute to a third-party Symfony bundle?

Related Related

  1. 1

    Can I change a dll reference within a third-party dll?

  2. 2

    Can I load a third-party .dll in R?

  3. 3

    How to reference and ship an external / third-party .NET DLL within a solution under version control at Visual Studio?

  4. 4

    How can I make my application find a third-party DLL using Visual Studio?

  5. 5

    Troubleshooting PInvokeStackImbalance with a third party DLL

  6. 6

    Capture Third Party DLL events in WCF

  7. 7

    Weird NullReferenceException in third party dll: C#

  8. 8

    CMake - install third party dll dependency

  9. 9

    I can not use the properties and variables of a library of classes within a dll

  10. 10

    How to make a third party plugin for Qt using another DLL?

  11. 11

    Using third party dll in Qt (No .lib file available)

  12. 12

    VSTO Outlook 2013 third party dll not being found

  13. 13

    How to make a third party plugin for Qt using another DLL?

  14. 14

    Using third party dll in Qt (No .lib file available)

  15. 15

    SharePoint 2010 Sand box solution does not work with third party DLL

  16. 16

    Create a wrapper around a third party dll to abstract the dll and to be able to unit test my code

  17. 17

    Compile Brotli into a DLL .NET can reference

  18. 18

    appharbor: thirdy party .dll and GAC referenced .dll

  19. 19

    appharbor: thirdy party .dll and GAC referenced .dll

  20. 20

    Can I write a class within an ASP.NET site without compiling a DLL?

  21. 21

    Ambiguous invocation of third party reference

  22. 22

    How can I find which projects reference a specific dll in my solution?

  23. 23

    How can I add a SWIG-generated C++ DLL reference to a C# project?

  24. 24

    How can I reference FakeLib.dll in a Fake.Deploy deployment script?

  25. 25

    How can I find which projects reference a specific dll in my solution?

  26. 26

    Using DirectX within a Dll

  27. 27

    How can I full parsing HTML without third party library?

  28. 28

    How can I use a third party Class Object as Hashmap Key?

  29. 29

    How can I contribute to a third-party Symfony bundle?

HotTag

Archive