尝试在NuGet控制台上更新包时出现以下错误
At line:1 char:1
+ Update-Package Microsoft.AspNet.WebApi -reinstall
+ CategoryInfo : InvalidOperation: (:) [Update-Package],
InvalidOperationException
+ FullyQualifiedErrorId :
NuGetMissingPackages,
NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
Run Code Online (Sandbox Code Playgroud)
当我尝试安装NuGet.PackageManagement.PowerShellCmdlets时,我收到错误
An error occured while trying to restore packages:Unable to find version '5.2.3' of package 'System.Net.Http.Formatting'.
Run Code Online (Sandbox Code Playgroud)
在.csproj文件中,System.Net.Http.Formatting的版本为5.2.3
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.Formatting.Extension.5.2.3.0\lib\System.Net.Http.Formatting.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
在packages.config文件中,System.Net.Http.Formatting的版本为5.2.3
<package id="System.Net.Http.Formatting" version="5.2.3" targetFramework="net461"/>
Run Code Online (Sandbox Code Playgroud)
在引用的属性中,版本为4.1.1.2,运行时版本为v4.0.30319,用于System.Net.Http.Formatting
所以我的问题是我无法重新安装System.Net.Http.Formatting,因为它现在显然是Microsoft.AspNet.WebApi的一部分,当我尝试安装它时,我得到原始错误.我绕圈子走了.如果我只是运行项目,它会编译,我得到运行时错误
Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.6.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
The located assembly's manifest definition does not match the assembly
reference. (Exception from …Run Code Online (Sandbox Code Playgroud) 我有一个问题,以便我可以更好地理解NuGet包packages.config和.csproj文件。
据我了解,默认包管理格式的 NuGet 包管理器 >> 常规中的设置决定了您的项目是否使用packages.config或.csproj文件来解析和恢复包。在我的项目中,我们选择了 Packages.config。
编译和运行没问题。因此,我决定测试它是否可以在文件dll中没有引用的情况下运行.csproj,因为据我所知,它不使用或不需要它。这是一个不正确的假设,就好像包在文件中一样packages.config,当我删除文件中的引用时,.csproj我的项目中出现错误,并且项目将无法编译。
我还注意到,如果dll不在参考文献中,Solution Explorer它也无法编译(我假设这些是.csproj参考文献)。
因此,我不清楚包管理格式.csproj文件的作用以及.Packages.configNuGetSolution Explorer
我有以下代码。我的问题是如何动态地将 autopostback 属性添加到按钮?
Button button = new Button();
button.ID = "Button" + i;
button.Text = "Save";
button.Click += SaveButton_Click;
PlaceHolder1.Controls.Add(button);
Run Code Online (Sandbox Code Playgroud)
像这样的东西button.autoPostBack = true;
我已经实现了Identity,Asp.Net.Core MVC 3因为我们已经有了要使用的数据库表。调用下面的方法时出现错误,并且它们都发生在UserManager对方法的同一个调用中。查看此方法的源代码是因为 Store 变量为空。但我不太确定如何确保它不为空。我在网上查看了各种解决方案,但没有一个能解决我的问题。
我的解决方案正在使用SignInManagerfor 密码,但我无法让它通过 Roles 的错误。
配置服务方法
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddMvc(options =>
{
var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
options.Filters.Add(new AuthorizeFilter(policy));
options.EnableEndpointRouting = false;
});
services.AddDbContext<EntitiesModel>(options => options.UseSqlServer(
Configuration["Data:ConnectionStrings:XXXXXXXXXXXXX"]));
services.AddIdentity<UserViewModel, UserRoleViewModel>().AddDefaultTokenProviders();
services.AddTransient<IUserStore<UserViewModel>, UserStore>();
services.AddTransient<IRoleStore<UserRoleViewModel>, RoleStore>();
services.ConfigureApplicationCookie(options =>
{
options.Cookie.HttpOnly = true;
options.LoginPath = "/Login";
options.LogoutPath = "/Logout";
});
}
Run Code Online (Sandbox Code Playgroud)
用户存储类
public class UserStore : IUserStore<UserViewModel>, IUserPasswordStore<UserViewModel>, IUserEmailStore<UserViewModel>, IUserRoleStore<UserRoleViewModel>
{
....
Run Code Online (Sandbox Code Playgroud)
RoleStore类
public class RoleStore …Run Code Online (Sandbox Code Playgroud)