[Solved] Can’t include Microsoft.Security.Application?

I can’t include Microsoft.Security.Application

using Microsoft.Security.Application;

Gives this error:

The type or namespace name ‘Security’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?)

And yes, I clicked on Bin -> Add Reference… -> AntiXSSLibrary.dll and it added it to the Bin Folder including the AntiXSSLibray.xml.

I rebuilt the whole website, and still nothing.

I’m using ASP .NET 3.5 C# – AntiXSSLibrary 4.0 Stable

Enquirer: Danpe


Solution #1:

Right mouse on your website -> Convert to webapplication. See: How To Convert ASP.NET Website to ASP.NET Web Application

Respondent: Polity

Solution #2:

If you get this nuget all extention objects are visibles

Install-Package AntiXSS

it solves my problem.

html = Microsoft.Security.Application.Encoder.HtmlEncode(model.SiteName),
model = Microsoft.Security.Application.Encoder.HtmlEncode(json),

Solution #3:

Uninstall and re-install AntiXSS:

Tools –> NuGet Package Manager –> Package Manager Console (UI may differ if using other than Visual Studio 2013):

Uninstall-Package AntiXSS
Install-Package AntiXSS

For multi-project solutions, be sure to set the default project to whichever one is experiencing the problem. Use Uninstall-Package -Force AntiXSS if uninstall fails and if you can handle any package dependency problems that may arise, though I know of none for this package.

Respondent: Charles Burns

Solution #4:

If, like me, you’re using AntiXSSLibrary in a class library via Nuget, and got the above error:

  1. Remove all external references that you had through Nuget
  2. Remove the Nuget package file – which is packages.config found in the solution’s root directory
  3. Remove the packages directory – again in your solution’s root directory
  4. Reinstall all your components again
Respondent: Druid

Solution #5:

The answer here helped me. I found the AntiXssLibrary.dll on my site’s bin folder.

Respondent: MiddleKay

Solution #6:

You are using
using Microsoft.Security.Application;

Try this
using System.Web.Security.Application;

For me, it was the other way round. I think it is due to different versions of my AntiXSSScripting dll I’m using.

Respondent: Shree Harsha

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.