Tuesday, August 25, 2009

Unblocking Assembly Due to AspNetHostingPermission Security Exception

Ok, 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.”

SecurityException

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.”

UnblockAssemblyIt 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!

No comments:

Post a Comment