I had a problem running my C# application throwing the following error when trying to use a certain reference as follows:
Could not load file or assembly 'My3rdPartyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)"
Then I followed this answer for signing the assembly in question.
I can confirm via Visual Studio and Sn as well that my DLL is now definitely signed and has a strong name.
However I am seeing 2 things:
I am out of clue on what could be the reason.
Thx for the help.
It turns out that I was able to solve it. I was updating the third-party library (the assembly that I want to sign) so that it can work well with my .exe BUT it gets replaced by an unsigned version that came from the NuGet package.
You'll have to update the .dll in the following location:
I will have instruction for an example package named WPFCustomMessageBox.dll. Follow the ff. steps to update the package and have it reflect on the debug folder:
cmd
in the path provided above.a. This one gets the necessary files from the .dll
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\Ildasm.exe" /all /out=WPFCustomMessageBox.il WPFCustomMessageBox.dll
b. I'm not sure what this one does but it preps the file for the next command.
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Ilasm.exe" "WPFCustomMessageBox.il" /dll /resource="WPFCustomMessageBox.res" /key="publickey.snk"
c. This one creates the signed .dll
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\sn.exe" -R "WPFCustomMessageBox.dll" "pair.pfx"
I've tested this method with the aid from Adding a Strong Name to a Third-Party Assembly. The next time you compile, the former unsigned .dll that gets compiled/copied over to the Debug folder should be signed. Hope this helps :)
User contributions licensed under CC BY-SA 3.0