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
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),
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.
Right mouse on your website -> Convert to webapplication. See: How To Convert ASP.NET Website to ASP.NET Web Application
If, like me, you're using AntiXSSLibrary in a class library via Nuget, and got the above error:
Remove all external references that you had through Nuget
Remove the Nuget package file - which is packages.config found in the solution's root directory
Remove the packages directory - again in your solution's root directory
Reinstall all your components again
The answer here helped me. I found the AntiXssLibrary.dll on my site's bin folder.
Install-Package AntiXSS from Tools --> NuGet Package Manager
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.
Related
This is what I did:
went to
https://www.twilio.com/docs/authy/tutorials/account-verification-csharp-mvc
downloaded the code and built the code using VS2017 community edition.
I get the following error in IdentityConfig.cs
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'TwilioRestClient' could not be found (are you missing a using directive or an assembly reference?) AccountVerification.Web C:\Users\admin\Downloads\account-verification-csharp-master\account-verification-csharp-master\AccountVerification.Web\App_Start\IdentityConfig.cs 21 Active
What is the problem?
I changed nothing. Just downloaded and built the code. Shouldn't you guys give a working copy of the code?
I've managed to get this working by following these steps:
Close the solution in Visual Studio if you have it opened.
Ensure you have a nuget CLI in your path. So you can run a restore from a command prompt. This is pretty straightforward. Instructions here.
Open a command prompt at the solution directory. (C:\Users\admin\Downloads\account-verification-csharp-master\account-verification-csharp-master for you.)
Run a nuget restore. nuget restore and wait for it to finish.
You should get all the packages downloaded at the packages directory under your solution folder.
UPDATE - Looking at the code it appears that there's a mix of features from the latest version 5.x and the now deprecated version 4.x, and that's causing compilation errors. Details here.
Follow the below steps to downgrade the version to 4.7.2:
Open the solution file now.
Right-click the web project and select Manage Nuget Packages.
Search for Twilio and downgrade the version from 5.x to 4.7.2.
a) Or from the Package Manager Console Install-Package Twilio -Version 4.7.2
Solution should build successfully now.
Please bear in mind that you must setup the parameters in Local.config file before the app can work. It'll run though, but you'll not be able to go through it until the parameters are properly set.
Note: The solution contains a file named Local.config.example. When you open the solution you'll notice that Local.config file is missing.
Renaming the existing Local.config.example file to Local.config solves that issue. I had to copy the Local.config file to the test project too. This doesn't prevent the solution from building, though.
Hope this helps!
perhaps Im getting old but Im really confused on how to use a nupkg on Linux. Resolving and installing dependencies/adding libs for C is easier for me (never would thought I would say so).
I got a package from a vendor (YYYYY_linux.3.0.77.nupkg) and want to run their example code (version for windows with visual studio worked out of the box) but they told me their linux pack would also work.
What I did:
dotnet init
... coding ...
dotnet restore
dotnet build
/home/tobiass/code/XXXX/Program.cs(27,11): error CS0246: The type or
namespace name 'YYYYY' could not be found (are you missing a using
directive or an assembly reference?)
Afterwards I tried two things:
1.
I edited NuGet.Config
dotnet restore
The nupkg shows up as a feed.
But I still get the same error.
2.
I also tried to create a local feed
mono nuget.exe add ../YYYYYYY_linux.3.0.77.nupkg -source ./
but it always results in
The requested feature is not implemented.
What is the correct way on Linux to add a library? Must it be also a part of project.json? Some config in .nuget?
Best,
Tobias
I suspect your project is not a .NET Core project so you should be using nuget.exe instead of dotnet.
So first I would take a look at the example code. Does it have a .csproj file? Does it have a packages.config file? Does it have a packages folder with the .nupkg file in it already? If so then nothing needs to be done and it should just compile.
From the error message one or more of the above are not correct. If the project file (.csproj) has references to the files in the NuGet package and there is an existing packages.config file then all you need to do is restore the package. To do that you need to put the NuGet package somewhere so it can be restored. You could simply just copy the .nupkg file into ~/.local/share/NuGet/Cache/ which is the machine cache for all NuGet packages and then restore it into the project by running nuget restore Path/To/YourSolution.sln.
If the project does not have a packages.config file then you would need to install it into the project. The simplest way would be to use MonoDevelop. That has built-in support for adding NuGet packages to projects.
Otherwise you could just unzip the .nupkg file and copy the files where they need to go into the solution's packages directory based on the information in the .csproj file.
I am trying to write a C# interactive script (.csx) that needs to use a NuGet package, but I must be overlooking something fundamental because I can't get it to work.
I tried adding a project.json that refers to the package, and it gets installed into the global packages dir when I nuget restore, but it seems the #r directive does not look there. I failed to find a relevant documentation on how the #r directive work (most docs seem to deal with the similar but different project called ScriptCS).
How do you write a csx script that references NuGet packages?
Dotnet Script has support for referencing Nuget packages in CSX files:
#r "nuget: AutoMapper, 6.1.0"
https://discoverdot.net/projects/dotnet-script#nuget-packages-1
C# Interactive can't reference NuGet packages, but scriptcs can.
This wiki entry has a note for the Interactive Window saying that you need to reference directly the NuGet DLL. So you could use the absolute path to the DLL in the global packages directory. It's not ideal, but should work.
Very simple from Visual studio UI:
Right click the project, Click Manage NuGet Packages
Selected the NuGet Package from the list in Browse or Installed tab and click the nuget.org URL
URL will lead to this webpage, Go to Script and Interactive tab, then simply click the copy button and paste it in your CSI in Visual studio or *.csx file
The solution is quite simple if you have ever worked with FSharp before, but the main
solution is:
#r "nuget:Newtonsoft.Json"
Above gets the latest package version. But if you want to specidy a version this works.
#r "nuget:Newtonsoft.Json,1.20"
If you happen to be working with external nuget sources, you should initialize that source with.
#i "nuget:http://example.com"
for sources on the web and
#i "nuget:C:\Nuget"
```for sources on your local file system
I have made a dll that wraps around some Google operations. With my first test drive it worked perfectly, but now in a real program, I get a weird assembly reference problem:
FileNotFoundException was unhandled
Could not load file or assembly 'Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Det går inte att hitta filen.
I have heard of System.Threading.Tasks (and am "using" it), but where does Microsoft.Threading.Tasks come in? The exception occurs at the last row of the snippet below.
Google.Apis.Admin.Directory.directory_v1.Data.Groups allGroupsResp = null;
var req = DirectoryService.Groups.List();
req.Domain = _settings.Domain;
allGroupsResp = req.Execute();
And there is no Microsoft.Threading.Tasks in the assembly list.
This is what worked for me:
Open the NuGet console via the Tools menu > NuGet Package Manager > Package Manager Console
From the console type in: update-package Microsoft.Bcl.Async -reinstall
After that, you may be prompted to re-start Visual Studio to finish uninstalling the package. Once you re-start, the package should be re-installed and everything should work.
Sounds like you're using the Google API .Net Client. I suggest using Nuget to install the assemblies as described on the linked page. However, if you download the source, the Microsoft.Threading.Task assmeblies are included and so it seems the code your calling is trying to access those assemblies.
You could manually move that assembly into your directory but I'd usually opt for the Nuget method unless you need to be using a particular build.
I expect you are using the "google-api-dotnet-client". Microsoft.Threading.Tasks is a dll used by this client according to google code:
https://code.google.com/p/google-api-dotnet-client/source/browse/ThirdParty/Microsoft.Threading.Tasks.dll
You probably just have to move this file into your bin directory.
Just install Microsoft.Bcl.Async nuget package!
(if you are using Google.Apis.Oauth2.v2 with UWP app)
There could be several problems - the first one you project where you've referenced this dll is not targeted to .Net4 or you just have not installed .Net4 framework on your box.
I had a similar problem with Microsoft.Threading.Tasks.PDB not being found.
Found the solution here: Cannot find .cs files for debugging .NET source code
TL;DR: VS was trying to debug the .NET framework and I was missing the debug files. But I did not actually need to debug the .NET so i did:
Tools -> Options -> Debugging -> General -> Enable just my Code
So im downloading a project at home from work over team foundation server. I download the project and it won't compile because of the error. Warning 2 The referenced component 'EntityFramework' could not be found. Could anyone offer guidance in how I can get entity framework to work. I installed nuget package.
Thankyou
I suggest you to check:
1) "Allow NuGet to download missing packages during build" ticked
Tool --> Options... --> Package Manager --> General
2) "Project selected" ticked
Solution Explorer --> right-click on the solution/project --> Manage NuPackages
3) Rebuild Solution
EDIT
For completeness I would like to add that if you are working with a CI system (e.g. Jenkins) or you are using MSBuild on the command line, you need to select Enable NuGet Package Restore to make it work:
Enable NuGet Package Restore http://docs.nuget.org/docs/Workflows/images/enable-package-restore.png
I had the same problem. I solved it like this:
Choose References > Right-click > Add Reference ...
Choose Browse tab
Find your Project Folder > packages > EntityFramework.4.1.10331.0 > lib
Choose EntityFramework.dll
Click OK
This happened to me, after I moved projects to a subfolder.
Then, the relative paths to the packages folder were not correct anymore.
Got errors like that:
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets. PROJECTNAME D:\VSTS\TEAMPROJECT\src\PROJECTFOLDER\PROJECTNAME.csproj
Fixed it by editing the *.csproj file and corrected the relative paths, in my case from ..\packages to ..\..\packages
Also make sure to check the paths under
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
There are good ways suggested by the developers, you may also try this solution to solve your problem.
In your case your project has a reference to the EntityFramework library, but library it self is not available to you project. You may try either the following:
If you have NuGet package manager:
Click on Project-> Manage NuGet Packages. It will open following window.
Find the EntityFramework and click Install.
- Alternatively, Download the EntityFramework library to your computer, then
Right-Click the Prject-> Add References...-> Browse-> Locate your
EntityFramework library-> Click OK
- Optionally you may use package manager to install library reference, check this link package-manager-console (Note: This might require NuGet Package manager)
I solved this issue by adding Entity Framework reference (Add ref) under C:\ Prog Files\Entity...\Binaries\Entity Framework.dll into my project. Hope this helps!
An old thread, but for anyone that this may help..
What worked for me was to go to the 'Packages' folder in the root of my solution and delete the EntityFramework.6.4.4 folder.
Then, go to Manage Nuget Packages menu option, and this banner pops up:
After pressing Restore the missing reference was restored.