Can't include Microsoft.Security.Application?
Asked Answered
E

7

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

Exemplify answered 12/5, 2011 at 14:51 Comment(12)
is AntiXSSLibrary.dll the correct library? It doesn't seem to agree with you.Poppas
Are there any warnings/messages? Look at your output window.Venality
No Warnings/Messages. And what you mean is the correct library. Offcourse it is.Exemplify
Is there a naming conflict? A class called Mirosoft? Try adding the namespace using global ( using global::Microsoft.Security.Application; )Venality
@Venality Yes it's conflicting with the Microsoft namespace.. global::Microsoft.Security.Application; Wont work either.Exemplify
@polity Nope :( it didn't fix itExemplify
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?Venality
@polity Nope cant see it there.Exemplify
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 youVenality
It's not project, it's a website So i cant Edit/Clean project? tried Rebuilding removing deleteing readding.. and nothing..Exemplify
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 differencesVenality
Thanks !!! That worked ! I followed this tutorial: how-to-convert-asp-net-website-to-asp-net-web-application Type you full answer so i can mark it as answer :)Exemplify
V
2

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

Venality answered 14/5, 2011 at 20:52 Comment(0)
H
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),

Hostler answered 29/1, 2016 at 22:45 Comment(0)
R
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.

Randi answered 2/3, 2016 at 0:0 Comment(0)
V
2

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

Venality answered 14/5, 2011 at 20:52 Comment(0)
D
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
Dollarbird answered 20/10, 2011 at 15:51 Comment(0)
U
1

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

Uvular answered 29/7, 2013 at 3:17 Comment(0)
O
1

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

Orthohydrogen answered 14/10, 2021 at 4:8 Comment(0)
P
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.

Prevost answered 1/9, 2017 at 11:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.