Why would you still get "Strong name validation failed"?

There are not many web pages mentioning this so I would just post this so it comes up in search. Having personally spent 4 hours tracking this little thing down, I would want anyone else to go through same :).

So... if you are using delay signing, you will need to run the following command so you can still debug from Visual Studio.Net:

sn -Vr *,[public key token]

Apparently if you are using Vista 64-bit it just won't work! You will still keep getting error something like,

Could not load file or assembly '[Your file], Version=2.0.0.0, Culture=neutral, PublicKeyToken=[public ket token]' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

You can try viewing Fusion log, cleaning solution, rebooting machine, watch FileMon, run Process Explorer, rebuild everything 10 times... but it just won't work. Infect if you try removing signing and if your app is WPF 3.5 then you might even get even more weird errors like

Could not create an instance of type 'StaticExtension'

The solution is hidden in a one liner in Dan Wahlin's blog:

If you're running a 64-bit installation of Vista you'll need to use the sn.exe located at C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\sn.exe

I'm pretty sure tons of developers adopting shiny 64-bit OS are/would run in to this. The root cause here is sn.exe designed for 32-bit doesn't error out instead it happily lets you know that "Verification entry added for assembly '*,* '" successfully! It's not! So I also filed a bug in out Connect web site. Please vote to make 64-bit world a better place!

Comments

  • Anonymous
    September 04, 2008
    Thank you for posting this....It worked for me.

  • Anonymous
    September 04, 2008
    Thank you for posting this....It worked for me.

  • Anonymous
    December 01, 2008
    Didn't work for me. I get the "Verification entry added for assembly" message, but then it still doesn't work. I also tried to verify with -v, and I still get message saying verification failed. Are there any suggestions for how to debug this?

  • Anonymous
    February 13, 2009
    THANK YOU! Just saved me a huge amount of trouble.  :D

  • Anonymous
    July 15, 2009
    Thanks for saving me from hours of trouble

  • Anonymous
    July 28, 2009
    Thanks a lot, it works for me too

  • Anonymous
    August 06, 2009
    Thanks, this helped a lot. One thing, it isn't that the 32 bit version doesn't work on x64. It just writes to the 32 bit registry hive so it will work if your main process that is trying to load the assembly is a 32 bit process. Otherwise, if it is a 64 bit process, then you would need to have the entry in the 64 bit registry hive.

  • Anonymous
    September 03, 2009
    Thank you so much. I wasted hours trying to figure out why skipping strong name validation wasn't working for my assembly. It's because it was a 64-bit assembly!

  • Anonymous
    October 01, 2009
    Thanks as so many other have said! I spent about 2 hours on this until I found your post :o)

  • Anonymous
    October 05, 2009
    thank you for the info, I installed vmware with xp as guest os and tried to work around as I could not resolve the problem, untill I stumbled accross your post... thanks again for sharing one happy :) Jay

  • Anonymous
    October 13, 2009
    It seems that the converse is true here too - if you're on a 64-bit machine and you want to skip strong name validation for a 32-bit process, you have to use the 32-bit version of sn.exe to do this.  Running the 64-bit version against a 32-bit process did not resolve the problem for me.

  • Anonymous
    December 08, 2009
    Bless u man...u saved me alot of time

  • Anonymous
    January 17, 2010
    Really helpful. Wasted many hours on this :(

  • Anonymous
    January 27, 2010
    Thanks a lot, works on Windows 7 64-bit as well! Wout

  • Anonymous
    February 26, 2010
    Thanks a lot, after I have already wasted some time, this saved me. (WIN7 64bit, VS2008)

  • Anonymous
    March 23, 2010
    Thanks a million, man. I have spent almost an entire day trying to figure this out until I came across this post!

  • Anonymous
    April 19, 2010
    thanks so much! was having this issue on Win7 for the past few hours and was pulling my hair out, I was using the one in bin rather than binx64 (arghhhh!!!)

  • Anonymous
    May 03, 2010
    Hey Man!! Thanks alot, I was facing this issue from long and as I googled I got ur post the first and it really gave solution in 10 secs!! Awesome :)

  • Anonymous
    August 16, 2010
    The comment has been removed

  • Anonymous
    August 23, 2010
    Thanks a lot !! Worked for me. (Win Server 2008 64bit + VS 2008 SP1)

  • Anonymous
    October 14, 2010
    WIN7 64bit, VS2010.  This didn't quite work, but it put me on the right path.  With VS2010 and .NET 4.0 there's now 4 sn.exe's: 32 bit .net2, 64bit .net2, 32bit .net4, and 64bit .net4.  I had to be sure to call the 64bit, .net4 sn.exe

  • Anonymous
    December 19, 2010
    Cheers mate that saved me. Had been trying different stuff for almost an hour!

  • Anonymous
    March 30, 2011
    Thanks from me too - I've been chasing this problem for days until I realised that even though sn was telling me I had an exception for my EXE it was a 64-bit exception and not a 32-bit exception. Would it be too big a deal to have one version of sn.exe that updated/displayed from all the registry hives?

  • Anonymous
    April 30, 2011
    I had to change the project settings from Any CPU to x86, then it worked!

  • Anonymous
    September 27, 2011
    Nice one, I was having the same problem - it had me baffled.

  • Anonymous
    March 27, 2012
    That solved my problem. (64 bit OS users) But just remember to use the full path "C:Program FilesMicrosoft SDKsWindowsv6.0ABinx64sn.exe" -Vr *,a8571041c8aa085d instead of "sn" .....

  • Anonymous
    May 03, 2012
    That solved my problem as well. Thank you.

  • Anonymous
    November 27, 2012
    I have such exception when I run unit test in VS 2012, whereas in VS 2010. Do you have any ideas?

  • Anonymous
    May 24, 2013
    The comment has been removed

  • Anonymous
    August 05, 2013
    Thank you very much for this post, it saved my life.