brutaldev / StrongNameSigner

Strong-name sign third party .NET assemblies without the source code.
https://brutaldev.com/post/net-assembly-strong-name-signer
Other
320 stars 68 forks source link

Update InternalsVisibleTo to prevent exceptions at runtime #14

Closed GeertvanHorrik closed 9 years ago

GeertvanHorrik commented 9 years ago

Some resigned assemblies use InternalsVisibleTo. This causes runtime exceptions as you can read here:

https://catelproject.atlassian.net/browse/CTL-653?focusedCommentId=19053&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-19053

Details:

An exception of type 'System.MethodAccessException' occurred in Catel.MVVM.dll but was not handled in user code
Additional information: D:\DevSamples\StrongNameProblem\MyTestApp\bin\Debug\Catel.Core.dll Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations.
brutaldev commented 9 years ago

InternalsVisibleTo attributes are re-written with the new signed assembly public keys as of version 1.4.2. Invalid InternalsVisibleTo attributes are also removed as of version 1.4.4 which is the problem described in the exception above. The current version is 1.4.5.

To ensure this error does not occur, update StrongNameSigner to at least version 1.4.4 which will remove any InternalsVisibleTo attributes that were not updated with reference public keys after signing.

brutaldev commented 9 years ago

Please note that the invalid references will only be removed from assemblies that are signed by StrongNameSigner.

In the attached zip file from the link you sent, Catel.Core.dll and Catel.MVVM.dll are already signed (with invalid InternalsVisibleTo still in place). If you try to process these through the tool again, nothing will happen because they already have strong-name signatures and will not be modified.

Please re-sign the original files with version 1.4.4 or higher to have the InternalsVisibleTo attributes correctly removed.

GeertvanHorrik commented 9 years ago

Thanks for all the info, will let them know.