我有一个以前没有经历过的问题.即使我没有任何提交,并试图将我的分支重置为最新的提交Sourcetree显示Uncommitted changes
.
根据Atlassian论坛,通常有两个原因:
背景:我们正在开展的项目由多个共享两个库的解决方案组成。一切都写在.NET Framework 4.6.1
今天。该项目的目标是采用.NET Core
新项目并能够在Docker
.
随着新版本的发布.NET Standard 2.1
以及.NET Framework 4.8
将保留.NET Standard 2.0
而不是实施的事实,.NET Standard 2.1
感觉是开始的合适时机。微软的 Immo Landwerth 说:
但同样正确的是 .NET Framework 的创新速度必须放慢以减少损坏。从这个意义上说,您通常应该期望大多数新功能只会在 .NET Core(以及派生平台,例如 Xamarin、Mono 和 Unity,因为它们从与 .NET Core 相同的源构建)上可用。
https://blogs.msdn.microsoft.com/dotnet/2018/11/05/annoucing-net-standard-2-1/
我们希望能够访问新项目中的新功能,但不想将每个旧项目都转换为.NET Core
. 为了保持.NET Framework
和.NET Core
我们之间的兼容性,我们决定将我们的共享库转换为.NET Standard 2.0
.
https://docs.microsoft.com/en-us/dotnet/standard/net-standard
除了以下依赖项之外,这非常有效:
1. System.Net.Http.WebRequestHandler - 已解决
用于像这样的客户端证书:
WebRequestHandler requestHandler = new WebRequestHandler();
//Add certificate if setting exists
if (!string.IsNullOrEmpty(pushEvent?.CertificateThumbprint?.Thumbprint))
{ …
Run Code Online (Sandbox Code Playgroud) 使用个人用户帐户升级 Blazor WebAssembly 时出现以下错误:
错误(活动)CS0618“SignOutSessionStateManager”已过时:“请改用“Microsoft.AspNetCore.Components.Web assembly.Authentication.NavigationManagerExtensions.NavigateToLogout”。
应该如何NavigateToLogout
使用?
当前代码:
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@inject NavigationManager Navigation
@inject SignOutSessionStateManager SignOutManager
<AuthorizeView>
<Authorized>
<a href="authentication/profile">Hello, @context.User.Identity.Name!</a>
<button class="nav-link btn btn-link" @onclick="BeginSignOut">Log out</button>
</Authorized>
<NotAuthorized>
<a href="authentication/register">Register</a>
<a href="authentication/login">Log in</a>
</NotAuthorized>
</AuthorizeView>
@code{
private async Task BeginSignOut(MouseEventArgs args)
{
await SignOutManager.SetSignOutState();
Navigation.NavigateTo("authentication/logout");
}
}
Run Code Online (Sandbox Code Playgroud) 我想在使用C#Web Api后端在TypeScript中开发我的React应用程序时使用热重新加载.我使用.Net框架而不是Core,所以我需要使用IIS或IIS Express.我可以使用webpack dev server
没有问题的前端热重新加载,但后来我无法访问API资源.我能做到吗?
我刚刚在我的应用程序中注意到一个非常奇怪的事情。我有一段代码,用于检查文件夹或任何子文件夹是否包含.xls
文件而不是.xlsx
. 这是因为我使用EPPlus
which 无法处理.xls
文件。在运行Windows 10 Home
下面代码的计算机上只返回.xls
文件而不返回任何.xlsx
文件。我现在尝试在一Windows 10 Pro
台机器上运行相同的代码,并且代码也获取了.xlsx
文件。我知道我只能.xls
使用文件,Linq
但我仍然想知道为什么会发生这种情况。
var filePaths = Directory.GetFiles("C:\\xmlfiles", "*.xls", SearchOption.AllDirectories).ToList();
if (filePaths.Count > 0)
{
var files = string.Join(",", filePaths);
throw new Exception($"Folder contains .xls files which EPPlus can't handle. Please convert them first. Files: {files}");
}
Run Code Online (Sandbox Code Playgroud) 我尝试fontWeight
在TypeScript中设置时出现此错误:
Types of property 'test' are incompatible.
Type '{ fontWeight: number; }' is not assignable to type 'Partial<CSSProperties>'.
Types of property 'fontWeight' are incompatible.
Type 'number' is not assignable to type '"inherit" | 400 | "initial" | "unset" | "normal" | "bold" | "bolder" | "lighter" | 100 | 200 | 30...'.
Run Code Online (Sandbox Code Playgroud)
即使400
是正确的数字,它也可以是任何数字,因此我得到错误,因为我理解它.我可以将此错误跟踪到React.CSSProperties,它指定fontWeight
应该如下所示:
fontWeight?: CSSWideKeyword | "normal" | "bold" | "bolder" | "lighter" | 100 | 200 | 300 | 400 | 500 | …
Run Code Online (Sandbox Code Playgroud) 由于Entity Framework将nvarchar(max)
字符串默认用作默认值,因此我想将其他内容设置为默认值。
在Entity Framework 6.1.3中,我可以这样修改OnModelCreating(DbModelBuilder modelBuilder)
:
modelBuilder.Properties<DateTime>().Configure(c => c.HasColumnType("datetime2"));
modelBuilder.Properties<DateTime>().Configure(c => c.HasPrecision(0));
modelBuilder.Properties<string>()
.Configure(s => s.HasMaxLength(256).HasColumnType("nvarchar"));
Run Code Online (Sandbox Code Playgroud)
如果随后我使用数据注释修改了属性,EF则改用这些值,如下所示:
[MaxLength(128)]
public string Name { get; set; }
[Column(TypeName = "nvarchar(MAX)")]
[MaxLength]
public string Comment { get; set; }
Run Code Online (Sandbox Code Playgroud)
但是使用Microsoft.EntityFrameworkCore.SqlServer 2.1.0
我不能做到这一点,我也不能使用Conventions
。
我可以这样解决,datetime
但是如果我尝试对字符串执行相同的操作,则迁移将表明type: "nvarchar(256)", maxLength: 128
是否使用例如数据注释。我该如何解决?
foreach (var property in modelBuilder.Model.GetEntityTypes()
.SelectMany(t => t.GetProperties())
.Where(p => p.ClrType == typeof(DateTime)))
{
property.Relational().ColumnType = "datetime2(0)";
}
Run Code Online (Sandbox Code Playgroud) 我们有一个面向客户的网站和一个用于创建用户的后台。当在我们的Developer机器上的IIS Express上运行两个应用程序时,使用带有重置密码的欢迎电子邮件创建新用户的过程是完美的。但是,当我们部署应用程序并将应用程序托管在具有不同应用程序池标识的不同IIS服务器上时,它将停止工作。
我们已经能够在同一台服务器上使用不同的应用程序池标识离线复制错误。如果我们进行切换,以使应用程序在IIS中使用相同的应用程序池标识,则一切将再次开始工作。
后台:
applicationDbContext = new ApplicationDbContext();
userManager = new ApplicationUserManager(new ApplicationUserStore(applicationDbContext), applicationDbContext);
var createdUser = userManager.FindByEmail(newUser.Email);
var provider = new DpapiDataProtectionProvider("Application.Project");
userManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser, int>(provider.Create("ASP.NET Identity"));
var token = userManager.GeneratePasswordResetToken(createdUser.Id);
Run Code Online (Sandbox Code Playgroud)
客户门户:
var applicationDbContext = new ApplicationDbContext();
userManager = new ApplicationUserManager(new ApplicationUserStore(applicationDbContext), applicationDbContext);
var user = await userManager.FindByEmailAsync(model.Email);
if (user == null)
{
return GetErrorResult(IdentityResult.Failed());
}
var provider = new DpapiDataProtectionProvider("Application.Project");
userManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser, int>(provider.Create("ASP.NET Identity"));
//This code fails with different Application Pool Identities
if (!await userManager.UserTokenProvider.ValidateAsync("ResetPassword", …
Run Code Online (Sandbox Code Playgroud) 我们已经通过服务连接(服务主体身份验证)在 Azure DevOps 和 Azure Key Vault 之间建立了连接。但是,为了使其工作,我们需要将Azure Key Vault
->Networking
标记为 Allow access from: All networks
。鉴于我们在这里存储机密,我们希望使用该选项Private endpoint and selected networks
而不是Allow trusted Microsoft services to bypass this firewall?
set to Yes
。
像这样:
但是,这会导致 Azure DevOps -> Pipelines -> Library 上的错误:
指定的 Azure 服务连接需要对所选密钥保管库具有“获取、列出”机密管理权限。单击“授权”以启用 Azure Pipelines 在 Azure 门户中设置这些权限或管理机密权限。
如果我们All networks
为 Azure Key Vault设置 Allow access from:它可以像前面提到的那样工作,但我们希望尽可能避免这种情况。
在管道中设置 Azure Key Vault 任务
或者设置一个变量组然后切换回Private endpoint and selected networks
导致部署时出现类似的错误。
MyKey:“客户端地址未授权且调用方不是受信任的服务。\r\n客户端地址:111.222.333.44\r\n调用方:appid= ;oid=00000000-0000-0000-0000-000000000000;iss= https:/ …
我间歇性地得到以下例外情况:
IOException: 无法从传输连接读取数据:由于线程退出或应用程序请求,I/O 操作已中止。
SocketException: 由于线程退出或应用程序请求,I/O 操作已中止。
系统正在查询外部资源,并且不时发生异常,但似乎没有任何异常。我试图设置更长的超时时间,HttpClient
但没有帮助。在异常发生之前,它可能是 5000-50000 次搜索,但我仍然想减轻它。如果我在异常之后直接重试相同的搜索,它会起作用,因此即使我无法访问该应用程序日志,接收方似乎也没有问题。运行.NET Core 3.1
。
我的服务.cs
public class MyService
{
private readonly HttpClient _httpClient;
public MyService(HttpClient client)
{
client.BaseAddress = new Uri("https://example.com/");
client.Timeout = TimeSpan.FromMinutes(5);
_httpClient = client;
}
private async Task<List<string>> GetValuesFromSearch(string search)
{
//Exception is thrown here
var response = await _httpClient.GetAsync("search/" + search);
using var responseStream = await response.Content.ReadAsStreamAsync();
response.EnsureSuccessStatusCode();
var searchResultList = await JsonSerializer.DeserializeAsync
<List<string>>(responseStream);
return searchResultList;
}
}
Run Code Online (Sandbox Code Playgroud)
像这样调用:
var myService = new MyService(new …
Run Code Online (Sandbox Code Playgroud) c# ×7
asp.net ×3
.net ×2
typescript ×2
.net-7.0 ×1
.net-core ×1
async-await ×1
asynchronous ×1
azure ×1
azure-devops ×1
blazor ×1
css ×1
epplus ×1
excel ×1
git ×1
iis ×1
javascript ×1
material-ui ×1
reactjs ×1