Unblocking Assembly Due to AspNetHostingPermission Security Exception
25 Aug 2009Ok, I am one of those strange birds who jumped over Windows Vista and went straight from Windows XP to Window 7, so I havenโt had the pleasure to experience many of the security features that supposedly protect the user from themselves.
After banging my head on the proverbial wall one too many times, I finally figured out the cause of a Security Exception I was getting while trying to add xVal Validation Framework into my ASP.NET MVC v2 Preview 1 project.
โSystem.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.โ
It appears that Windows 7 (and from what Iโve heard Windows Vista also does this as well) attempted to protect me from a potential threat! When looking at the file properties dialog of the xVal.dll there was a security message at the bottom statingโฆ
โThis file came from another computer and might be blocked to help protect this computer.โ
It turns out that all I had to do is click the โUnblockโ button next to the message, remove & readd my Visual Studio project reference, and viola my problems were solved!
Next time, I hope not to waste half my day trying to figure this out. If you have not already faced this pain, I hope that you donโt have to in the future, or that this post will help you resolve it quickly!