While working on signing assemblies you may run into a problem I encountered this morning so here goes…

Problem XamlBuildTask fails when referencing a Delay Signed assembly

To see this in action try the following

  1. Create a Workflow Console Application (WorkflowConsoleApp1)
  2. Create an Activity Library (ActivityLibrary1)
  3. Reference ActivityLibrary1 from WorkflowConsoleApp1
  4. Set ActivityLibrary1 to Delay Sign
    image
  5. Build and you will get this error

Build error occurred in the XAML MSBuild task: 'Could not load file or assembly 'file:///d:\spike\ActivityLibrary1\bin\Debug\ActivityLibrary1.dll' 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.

Problem: Visual Studio does not correctly update the state of the Delay Sign checkbox when loading a project

To make this problem even worse, try this. 

  1. Uncheck Sign the assembly
  2. Close the solution
  3. Open it again
  4. Open the project properties
  5. Check Sign the assembly
  6. Verify that Delay sign only is unchecked
  7. Build the solution - the error still occurs – why?

    image
  8. Unload the project and edit it
  9. Look for DelaySign in the project XML – even though the checkbox is unchecked, DelaySign is true in the project file
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>Test.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<DelaySign>true</DelaySign>
</PropertyGroup>

To correct this, just delete the DelaySign property group or set it to false.

Hope this saves you a couple of hours of troubleshooting.

Happy Coding!

Ron Jacobs
http://blogs.msdn.com/rjacobs
Twitter: @ronljacobs http://twitter.com/ronljacobs