Saturday, February 20, 2010

Could not load file or assembly 'AntiXssLibrary, Version=3.1.3524.16873, Culture=neutral, PublicKeyToken=d127efab8a9c114f' or one of its dependencies.




Exception:
Could not load file or assembly 'AntiXssLibrary, Version=3.1.3524.16873, Culture=neutral, PublicKeyToken=d127efab8a9c114f' or one of its dependencies.

Required permissions cannot be acquired.

Cause:
The hosting environment is configured for Medium Trust and AntiXssLibrary is compiled using the "unsafe code" flag by default.

Solution:
1. In order to test this on your development comp you'll need to go into your web.config file and add a node
<trust level="Medium"> somewhere between <system.web></system.web>

2. Download the source code for AntiXSSLibrary, located here: http://antixss.codeplex.com/SourceControl/changeset/view/28744# and click on Download button

3. Open up the project in Visual Studio and right-click on the AntiXSSLibrary project.

4. Build tab, uncheck "Allow unsafe code" as seen below. NOTE: This cant be done in version 3.1, so only try it in version 3.0



5. Add [assembly: System.Security.AllowPartiallyTrustedCallers()] to AntiXssLibrary project AssemblyInfo.cs (located under Properties folder), as seen below










6. Recompile the project, and then add the reference to your project and test.


References:
1. http://msdn.microsoft.com/en-us/library/ms998341.aspx
2. http://forums.iis.net/t/1164637.aspx
3. http://antixss.codeplex.com/Thread/View.aspx?ThreadId=44517



No comments:

Post a Comment

There was an error in this gadget