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:
- Right click and run Visual Studio as admin
- 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)
- Change the permissions on the “c:\windows\temp” folder to include Everyone
- Remove read only from all folder/files related to this project and code
- Move all the code to your primary C drive
- 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.
- 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”.
- 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
- Hit apply. Some directories may say “Access Denied” but it still works.
- 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.
- 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.
- 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.
- 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.
You can see where the error ID was added to the command and a decently useful message is displayed.
- 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.