0
votes

I want to make a change to an assembly (mysql connector net), I build the dlls successfully but when I try to run my web solution I get:

Could not load file or assembly 'MySql.Data' or one of its dependencies. Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key.

of course, I don't have the strong name key file to sign when I build the dll.

How can I make my project recognize the dll without having to verify with the strong name signature? or is there some other work around?

1

1 Answers

1
votes

A few things could be going on here and they'll require a bit of work to get around.

MySql.Data is strong name signed. To produce a MySql.Data.dll file that other, compiled, code can reference, you need to have access to the keypair used to sign the MySql.Data.dll file. You don't have access to that, only the MySql folks do (we hope, anyway), because leaking that would allow someone to create a malicious MySql.Data.dll and have other components which reference it use that .dll. Strong naming is designed to prevent that case.

My guess is that the MySql.Data project is configured to delay sign the .dll with the public portion of the keypair. You don't have the private portion of that keypair so you can't finish the signing process, yourself.

The solution is to generate a new key.snk file, configure the project to use that key, disable delay signing on that project and rebuild.

The problem you're going to run into is that any other libraries that reference MySql.Data.dll are going to be doing so with the strong name used in the proper MySql.Data.dll. So any other libraries that you're using which reference MySql.Data.dll will need to have their references modified with the strong name that your library now has.

You need to modify the references of these libraries (either by getting the source code or using ildasm.exe). You then have to change the references to use your library with the new strong name and rebuild those libraries. If these references are also strong name signed, you'll have to resign with a new key and repeat this same process with any libraries that reference that library.

You can imagine how this can spiral out of control pretty quickly. A better option, if it's possible, would be to create a new library that references the MySql.Data.dll and extend the classes/components that you've customized without touching the MySql.Data.dll library's code. This may, or may not, be possible depending on what behaviours you've changed with regard to that library.