brutaldev/StrongNameSigner

[Bug]: Getting `Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'mscorlib, Version=4.0.0.0` for x86 project

Closed this issue · 13 comments

Info on those dll's
image
image
image
image

image

Prior to applying strongNaming:
image

And the Log file:
image

I have the same problem:

5. Fix CustomAttributes with Type references...
6. Cleanup...
Error strong-name signing: Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

If it's caused by cleanup, can I force this error to be ignored and use the signed assemblies?

It's actually happening in Fix CustomAttributes with Type references...

Some strange types get resolved there and this is a new feature from @nickrandolph
If someone can provide a reproducible sample I will attempt to fix this or can just change the code to ignore these errors and potentially miss fixing from custom attributes.

@brutaldev If you want help, then do not close the issue(s)

Here is my output log after updating to v3.3.3:

5. Fix CustomAttributes with Type references...
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Windows.ThemeInfoAttribute': Failed to resolve assembly: 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Windows.ThemeInfoAttribute': Failed to resolve assembly: 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Resources.NeutralResourcesLanguageAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Security.SecurityRulesAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Windows.ThemeInfoAttribute': Failed to resolve assembly: 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   Failed to check custom attribute 'System.Diagnostics.DebuggableAttribute': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
6. Fix BAML references...
7. Save assembly changes...
   ...
   Failed to save assembly 'C:\...\build\Debug\DynamicExpresso.Core.dll': Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Do the final signed files will still work though? I need a sample to test and fix this with, when it was first reported no-one could provide a sample since it always works when using a simple project. #82

Provide a project/solution that reproduces this and I will be able to fix it.

@brutaldev I can supply the files privately, as they belong to a commercial product

@Smurf-IV Thanks, email me a link to the package or files that fail to werner@brutaldev.com
You do not need to include all files, just the ones that cause this issue to occur.

I've spent the morning looking into adding additional probing paths and creating assemblies with DebuggableAttribute and ThemeInfoAttribute attrbutes, x86 and Any CPU builds etc etc and cannot reproduce this.

3.3.3 no longer "Goes boom" but it just fails to save instead:
image

@Smurf-IV You're using a faulty SNK file there. The error is Keyset does not exist that prevents the saving and I can only imagine it's something wrong with your DelaySign.snk file that is used for the signing.

https://improveandrepeat.com/2018/12/how-to-fix-the-keyset-does-not-exist-cryptographicexception/

That file is generated via the following:

  • In a "Visual Studio command line", type

sn -p "########.pfx" DelaySign.snk

  • It will ask for the "CERT_PASSWORD" to be typed in

i.e. the ###.pfx file is not installed in either the developers machine or the build agent.

When running a clean build - only the Step 5 Failed ... error is displayed.
So I assume Step 7 is due to the files already being signed (by this tool)

@Smurf-IV What you are reporting now is a completely different issue to this one about resolving dependencies.
I've created a new issue for this: #93