brutaldev / StrongNameSigner

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

Operation is not valid due to the current state of the object. #40

Closed GieltjE closed 7 years ago

GieltjE commented 7 years ago

When creating an empty project with NodaTime v2.1.0 and StrongNameSigner it becomes imposible to launch the project:

Severity Code Description Project File Line Suppression State Error Operation is not valid due to the current state of the object. at Mono.Cecil.ModuleDefinition.ProcessDebugHeader() at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader) at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters) at Mono.Cecil.ModuleReader.CreateModuleFrom(Image image, ReaderParameters parameters) at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters) at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) at Brutal.Dev.StrongNameSigner.SigningHelper.GetAssemblyInfo(String assemblyPath, String[] probingPaths) at Brutal.Dev.StrongNameSigner.AutomaticBuildTask.Execute() WindowsFormsApp19

brutaldev commented 7 years ago

Machine/environment specific error, duplicate of issue #32. You can try sign on another machine or even a VM and it will work.

This occurs inside Mono.Cecil so you could try report this on their repo: https://github.com/jbevain/cecil According to a very old bug in Mono.Cecil on the same method call, this happens when the PDB is out of sync with the assembly, try clean and rebuilding your project: http://markmail.org/message/rfsybwk7waearubw

When I moved to the latest version, file locks occurs causing more problems but I think this will still happens when PDB does not match the assembly.

GieltjE commented 7 years ago

When I launch a separate project with just StrongNameSigner it can sign the dll, it just happens when trying to debug an project with both assemblies in them (immediately after the compile operation).

brutaldev commented 7 years ago

Still a Mono.Cecil problem. This happens when simply trying to read assembly information, it's not even trying to sign things yet. Would have to prevent symbol reading on line 460 which is enabled if symbols are found with the same name as the assembly you are signing. If symbol reading is disabled, the same stack trace (inside Mono.Cecil) would not occur and bypass this issue.