How to Disable Strong Name Verification for All .Net assembly?
Asked Answered
M

4

19

How to Disable .Net Strong Name Verification for All .Net assembly in system by config .net framework or IIS or project's config?

https://static.mcmap.net/file/mcmap/ZG-Ab5ovKR2RXVEQZFfxc5URKmMva3/up/726daf2c9ee0.png (click for larger image)

Manstopper answered 13/2, 2014 at 19:32 Comment(2)
You don't need to blank out your file names. No one cares what the file is called and it makes it harder to help you out.Catalan
see this social.msdn.microsoft.com/Forums/vstudio/en-US/…Boneyard
M
22

Try add it in regestry:

OS x32:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,af24b530b87e22f1]

OS x64:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,af24b530b87e22f1]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\*,af24b530b87e22f1]

and add it to your Web.config:

<system.web>
   <hostingEnvironment shadowCopyBinAssemblies="false" />
</system.web>
Manny answered 13/1, 2015 at 13:3 Comment(1)
The Web.config change is an important step that the other answers I'd tried missed—thanks for calling it out.Assizes
D
17

To disable strong name validation for all assemblies on your machine you can run:

sn.exe -Vr *

from a Developer Command Prompt for VS201*

Dolan answered 12/2, 2017 at 2:5 Comment(2)
Ensure that you are using the right version (64 bit or 32 bit) of sn.exe. If your assembly is 64 bit and you disable strong name validation (sn.exe -Vr *) with a 32 bit sn.exe, it doesn't work. You need to use 64 bit sn.exe only to work.Triaxial
In order to avoid the confusion of 32 bit and 64 bit sn.exe, the best way to disable strong name verification is by directly modifying the registry by adding the below 2 entries. This makes your assembly to work for both 32 bit and 64 bit. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification*,] [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification*,]Triaxial
S
6

This is an exception I received:

Error Type: System.IO.FileLoadException
Error Message: Could not load file or assembly 'MyAssemblyName, Version=5.1.0.0,  Culture=neutral, PublicKeyToken=30b439e30eee46b4' or one of its dependencies.
Strong name  validation failed. (Exception from HRESULT: 0x8013141A)

This is a solution which worked for me to disable strong name validation for a particular assembly while testing it within totally signed service:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\MyAssemblyName,30b439e30eee46b4]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\MyAssemblyName,30b439e30eee46b4]

You have to create those new keys in the registry, keys have no values under them. You can copy these two lines into .reg file, change assembly name and its guid and double-click it to merge into the Registry.

Note: assembly name is your filename without .dll extension, exactly as it shows in the exception.

Then restart your app/service.

I think the answers above with * instead of assembly name should also work.

Sistrunk answered 16/8, 2014 at 23:59 Comment(0)
E
4

Below Entries will work:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,af24b530b87e22f1]
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\*,af24b530b87e22f1]
Equivalence answered 6/8, 2014 at 17:28 Comment(3)
Please be explicit about what needs to be done when mentioning registry keys. Delete them? Add them? Change them?Pantechnicon
You want to add these keys to the registry. The easiest way is by running a powershell command: reg ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification*,af24b530b87e22f1"Alexine
thats not PowerShell ;)Strife

© 2022 - 2024 — McMap. All rights reserved.