简体   繁体   中英

error CS0234: The type or namespace name 'OAuth' does not exist in the namespace 'Microsoft.Owin.Security' (are you missing an assembly reference?)

I am trying to build a project with cli:

msbuild.exe project.sln

I get errors of this type:

App_Start\NinjectConfig.cs(3,31): error CS0234: The type or namespace name 'OAuth' does not exist in the namespace 'Microsoft.Owin.Security' (are you missing an assembly reference?) [path_to_file\file.csproj]

I tried nuget restor Also I have in root directory of my project folder for packges in which you have packages\\Microsoft.Owin.Security.OAuth.3.0.1\\lib\\net45 with Microsoft.Owin.Security.OAuth.dll file.

In file.csproj I have a reference:

<Reference Include="Microsoft.Owin.Security.OAuth">
<HintPath>..\..\packages\Microsoft.Owin.Security.OAuth.2.1.0\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>

I can see the differences in versions, but there are 2 questions: 1) why visual studio is building this with no errors? How come it works with vs but not with cli? 2) Why is nuget installing wrong version? 3) How can I export from vs a config for nuget to install all packages?

I am a newbie - so be gentle please.

1) why visual studio is building this with no errors? How come it works with vs but not with cli?

Since we do not have your project/solution, we could not figure out the reason why the Visual Studio is building with no error. But if you resolve your latter two problems, you will not be confused about this problem.

2) Why is nuget installing wrong version?

NuGet not install the project to the project file when you use the nuget restore command line. This command line just Downloads and installs any packages missing from the packages folder , So it not change the nuget package version in the file.csproj when you use that command line, it just download the package Microsoft.Owin.Security.OAuth.3.0.1 and set it to the \\packages folder based on the nuget.config file, it will not check the HintPath in the project file. That is also the reason why you can see the nuget package in root directory of your project folder.

However, the path and version is not correct in the file.csproj ( Could not know the reason, may be accidentally changed manually or for other reasons ), it should be:

<HintPath>..\packages\Microsoft.Owin.Security.OAuth.3.0.1\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>

Single ..\\ and version is 3.0.1.

So, to resolve this issue, we should re-install the nuget package instead of restore it. You can uninstall it and reinstall that packages.

3) How can I export from vs a config for nuget to install all packages?

There is a packages.config file in your project, you can install the all the packages with Package Manager Console in Visual Studio, but you could not install all the packages with nuget CLI. Because package manager console is providing is access to visual studio objects.

Check another thread for some more details.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) Error CS0234 The type or namespace name 'Reporting' does not exist in the namespace 'Microsoft' (Are you missing an assembly reference?) Error CS0234 The type or namespace name 'Platforms' does not exist in the namespace 'MvvmCross' (are you missing an assembly reference?) error CS0234: The type or namespace name does not exist in the namespace (are you missing an assembly reference?) The type or namespace name 'OpenIdConnect' does not exist in the namespace 'Microsoft.Owin.Security' (are you missing an assembly reference?) CS0234 C# The type or namespace name 'Slydeextender' does not exist in the namespace (are you missing an assembly reference?) VS 2017 c# Error CS0234 The type or namespace name does not exist in the namespace (are you missing an assembly reference?) Compiler Error Message: CS0234: The type or namespace name 'WebApp' does not exist in the namespace 'Fax' (are you missing an assembly reference?) CS0234: The type or namespace name '<namespace2>' does not exist in the namespace '<namespace1>.' (are you missing an assembly reference?) MEF CS0234: The type or namespace name 'Composition' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM