Cryptographic failure while signing assembly – Unknown error 8013141c

Terrible title, but read the whole thing as this gets interesting.

First, if you are here because you have this error, or more specifically these 2 errors

SGEN Cryptographic failure while signing assembly … Error signing assembly — ¬†Unknown error (8013141c)
SGEN Unable to generate a temporary class (result=1)

then I have a number of options for you to try:

  1. Right click and run Visual Studio as admin
  2. Unmount the project, update the csproj file with some proxy related XML, remount project (this advice found elsewhere doesn’t even compile correctly in Visual Studio 2015 so I wont show the code)
  3. Change the permissions on the “c:\windows\temp” folder to include Everyone
  4. Remove read only from all folder/files related to this project and code
  5. Move all the code to your primary C drive
  6. Uncheck “Sign the Assembly” in the project properties (this works but is not an acceptable fix)

If like me you have been Googling for an answer all day, these are all you will find and none worked for me. Here are the steps that did work.

  1. You need to change security on directory or multiple directories. Most blogs pointed to “C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys” but sometimes that directory structure doesn’t exist. Search your C drive for “MachineKeys” and update each in order starting with “C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys”.
  2. A number of blogs mention to grant read/write permission to Everyone. That is not the best idea. Start with just your user, even if that use is already an Administrator on the machine like mine was. Then set the following permissions:
    • Create files / write data
    • Create folders / append data
    • Write attributes
    • Write extended attributes
    • Delete
  3. Hit apply. Some directories may say “Access Denied” but it still works.
  4. If this fails, grant Full Control to Everyone AND your specific user on all “MachineKeys” folders and recheck BUT DON’T LEAVE IT THIS WAY. If this works, start removing permissions until you figure out what is needed.
  5. Recompile in Debug mode and then Release mode to be sure. My issue only happened in Release mode.

Full credit to this blog for helping me figure this out http://aadhoc.blogspot.com/2010/05/cryptographic-failure-while-signing.html

Second, if you are still reading and wondering why I wrote this post then keep going, it gets interesting.

I wrote this post for 3 main reasons.

  1. Google Index vs Bing Index РI spent about a full work day searching the internet for an answer to this issue using Google. I have been a software developer professionally for almost a dozen years and I have found Google search to be better for most of my queries. The blog that contained the answer above; however, did not show up in any Google query but when I switched to Bing it was on page 2. My blog gets good indexing from Google so I hope this post is picked up for future searches.
  2. PowerShell Help – Even though I had found the answer, I still did not find any useful information on “Unknown error 8013141c”. A much better developer than me showed me this trick in PowerShell.
    PowerShell Tip
    You can see where the error ID was added to the command and a decently useful message is displayed.
  3. My Blog is my reference – Many technical posts I write are for my own benefit and I have gone back to my blog hundreds of times to look something up that I know I solved previously.

I hope this helps. Leave a comment if you found other ways to fix this issue or if you confirm it helped.

Tim Ferro