System.IdentityModel.Tokens.Jwt 未找到
System.IdentityModel.Tokens.Jwt not found
我想使用 C#(.Net Framework v 4.5)和 ASP.Net 开发 Sharepoint webhook。为此,我采用以下软件包:
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="AppForSharePointOnlineWebToolkit" version="3.1.2" targetFramework="net45" />
<package id="AppForSharePointWebToolkit" version="3.1.5" targetFramework="net45" />
<package id="bootstrap" version="3.4.1" targetFramework="net45" />
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
<package id="jQuery" version="3.4.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc.de" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor.de" version="3.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization.de" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client.de" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core.de" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost.de" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.de" version="3.2.7" targetFramework="net45" />
<package id="Microsoft.Azure.ActiveDirectory.GraphClient" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net45" />
<package id="Microsoft.Data.Edm" version="5.8.4" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net45" />
<package id="Microsoft.Data.Services.Client" version="5.8.4" targetFramework="net45" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="6.12.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Logging" version="6.12.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.4.403061554" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Protocols" version="5.5.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Protocols.WsFederation" version="5.5.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Tokens" version="6.12.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Tokens.Saml" version="5.5.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Xml" version="5.5.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.de" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb.de" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.ActiveDirectory" version="3.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.ActiveDirectory.de" version="3.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.de" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Jwt" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Jwt.de" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.OAuth" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.SharePointOnline.CSOM" version="16.1.5521.1200" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" targetFramework="net45" />
<package id="Modernizr" version="2.8.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="SharePointPnPCoreOnline" version="2.6.1608.0" targetFramework="net45" />
<package id="System.IdentityModel.Tokens.Jwt" version="6.12.0" targetFramework="net45" />
<package id="System.Spatial" version="5.8.4" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="9.3.3" targetFramework="net45" />
</packages>
但是我在下面的第一个启动后得到class这个消息:
TokenValidationParameters 中的编译器错误 CS0246 和 CS7069
Error CS7069 The reference to type "TokenValidationParameters" was supposedly declared in "System.IdentityModel.Tokens.Jwt" but could not be found.
和
Error CS0246 The type or namespace name "TokenValidationParameters" was not found (possibly missing a using directive or assembly reference).
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IdentityModel;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.IdentityModel;
using System.Linq;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.ActiveDirectory;
using Owin;
namespace WebApplication
{
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
TokenValidationParameters = new TokenValidationParameters {
ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
},
});
}
}
}
我做错了什么?
我在 C# 和 ASP.NET 方面没有太多经验。
错误 CS0246 的原因未找到类型或命名空间名称 “TokenValidationParameters”(可能缺少 using 指令或程序集引用)是
Microsoft.IdentityModel.Tokens .cs 文件中缺少程序集引用。
请在 class 文件中导入以下命名空间。
using Microsoft.IdentityModel.Tokens;
我想使用 C#(.Net Framework v 4.5)和 ASP.Net 开发 Sharepoint webhook。为此,我采用以下软件包:
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="AppForSharePointOnlineWebToolkit" version="3.1.2" targetFramework="net45" />
<package id="AppForSharePointWebToolkit" version="3.1.5" targetFramework="net45" />
<package id="bootstrap" version="3.4.1" targetFramework="net45" />
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
<package id="jQuery" version="3.4.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc.de" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor.de" version="3.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization.de" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client.de" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core.de" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost.de" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages.de" version="3.2.7" targetFramework="net45" />
<package id="Microsoft.Azure.ActiveDirectory.GraphClient" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net45" />
<package id="Microsoft.Data.Edm" version="5.8.4" targetFramework="net45" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net45" />
<package id="Microsoft.Data.Services.Client" version="5.8.4" targetFramework="net45" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="6.12.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Logging" version="6.12.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.4.403061554" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Protocols" version="5.5.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Protocols.WsFederation" version="5.5.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Tokens" version="6.12.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Tokens.Saml" version="5.5.0" targetFramework="net45" />
<package id="Microsoft.IdentityModel.Xml" version="5.5.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.de" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb.de" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.ActiveDirectory" version="3.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.ActiveDirectory.de" version="3.1.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.de" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Jwt" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Jwt.de" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.Owin.Security.OAuth" version="4.2.0" targetFramework="net45" />
<package id="Microsoft.SharePointOnline.CSOM" version="16.1.5521.1200" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" targetFramework="net45" />
<package id="Modernizr" version="2.8.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="SharePointPnPCoreOnline" version="2.6.1608.0" targetFramework="net45" />
<package id="System.IdentityModel.Tokens.Jwt" version="6.12.0" targetFramework="net45" />
<package id="System.Spatial" version="5.8.4" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="9.3.3" targetFramework="net45" />
</packages>
但是我在下面的第一个启动后得到class这个消息: TokenValidationParameters 中的编译器错误 CS0246 和 CS7069
Error CS7069 The reference to type "TokenValidationParameters" was supposedly declared in "System.IdentityModel.Tokens.Jwt" but could not be found.
和
Error CS0246 The type or namespace name "TokenValidationParameters" was not found (possibly missing a using directive or assembly reference).
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IdentityModel;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.IdentityModel;
using System.Linq;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.ActiveDirectory;
using Owin;
namespace WebApplication
{
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
app.UseWindowsAzureActiveDirectoryBearerAuthentication(
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = ConfigurationManager.AppSettings["ida:Tenant"],
TokenValidationParameters = new TokenValidationParameters {
ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
},
});
}
}
}
我做错了什么?
我在 C# 和 ASP.NET 方面没有太多经验。
错误 CS0246 的原因未找到类型或命名空间名称 “TokenValidationParameters”(可能缺少 using 指令或程序集引用)是 Microsoft.IdentityModel.Tokens .cs 文件中缺少程序集引用。 请在 class 文件中导入以下命名空间。
using Microsoft.IdentityModel.Tokens;