17

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 AntiXSSLibrary.xml.

I rebuilt the whole website, and still nothing.

I'm using ASP .NET 3.5 C# - AntiXSSLibrary 4.0 Stable

TylerH
  • 20,799
  • 66
  • 75
  • 101
Danpe
  • 18,668
  • 21
  • 96
  • 131
  • 1
    is AntiXSSLibrary.dll the correct library? It doesn't seem to agree with you. – asawyer May 12 '11 at 14:56
  • Are there any warnings/messages? Look at your output window. – Polity May 12 '11 at 14:56
  • No Warnings/Messages. And what you mean is the correct library. Offcourse it is. – Danpe May 12 '11 at 14:59
  • Is there a naming conflict? A class called Mirosoft? Try adding the namespace using global ( using global::Microsoft.Security.Application; ) – Polity May 12 '11 at 15:00
  • @Polity Yes it's conflicting with the Microsoft namespace.. `global::Microsoft.Security.Application;` Wont work either. – Danpe May 12 '11 at 15:03
  • @polity Nope :( it didn't fix it – Danpe May 12 '11 at 15:06
  • Right, i dont think namespaces can conflict with one another, only classes can conflict and namespaces with classes. E.g. if you had a class named Microsoft, then he would look op the Property Security on the class rather then the namespace Security in the namespace Microsoft. When using Object Explorer (Ctrl + Alt + J), can you find the namespace your trying to access? – Polity May 12 '11 at 15:11
  • @polity Nope cant see it there. – Danpe May 12 '11 at 15:21
  • Remove the reference, remove the DLL, Clean project, Rebuild project, Add reference again and try again. If that doesnt work, use a text editor and open [yourproject].vsproj and see if its referenced right. If that doesnt work, try and restart VS ;), else try and compile on another PC. It seems to me that Visual Studio is messing with you – Polity May 12 '11 at 15:22
  • It's not project, it's a website So i cant Edit/Clean project? tried Rebuilding removing deleteing readding.. and nothing.. – Danpe May 12 '11 at 16:07
  • 1
    Right mouse button on your website -> Convert to webapplication (for me this solved alot of problems coming with Website projects in the past) although i dont really understand why. Else, create a new website and try and reproduce the problem. If you cant, try and find the differences – Polity May 12 '11 at 16:33
  • Thanks !!! That worked ! I followed this tutorial: [how-to-convert-asp-net-website-to-asp-net-web-application](http://stackoverflow.com/questions/735054/how-to-convert-asp-net-website-to-asp-net-web-application) Type you full answer so i can mark it as answer :) – Danpe May 12 '11 at 21:00

7 Answers7

30

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),

5

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.

Charles Burns
  • 10,310
  • 7
  • 64
  • 81
2

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

Community
  • 1
  • 1
Polity
  • 14,734
  • 2
  • 40
  • 40
2

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
Druid
  • 6,423
  • 4
  • 41
  • 56
1

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

MiddleKay
  • 319
  • 4
  • 13
1

Install-Package AntiXSS from Tools --> NuGet Package Manager

Shehan Silva
  • 526
  • 4
  • 8
0

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.

Shree Harsha
  • 377
  • 3
  • 9