简体   繁体   中英

Strong name verification does not fail for modified assembly

I followed this video , and the steps I did were:

  1. I make a strong named assembly, a.dll from a C# class.
  2. I make b.exe from a C# class that has a reference for a.dll (a class like Program.cs in Console Application).
  3. I run b.exe, and it executes correctly.
  4. I modify the strong named a.dll, and verify that by sn -v a.dll command, and the response is: " Failed to verify assembly -- Strong name validation failed. "
  5. Again I run b.exe and it works, but I expect a FileLoadException error because it's a modified assembly. In this video the error occurs!

My results are not the same as seen in the video. Is there a reason for this?

I'm guessing you're using .NET 3.5 SP 1 or later, and I'm guessing the video is based on an earlier version, or has applied the below fix to disable the "Strong Name Signing Bypass".

Please visit How to: Disable the Strong Name Signing Bypass Feature

Starting with the .NET Framework version 3.5 Service Pack 1 (SP1), strong-name signatures are not validated when an assembly is loaded into a full-trust AppDomain ... Bypassing the validation of strong-name signatures provides significant performance improvements

So, they changed the rules, provided you're running in full-trust.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM