之前我使用 Unity 引擎 4.5 创建了一个游戏,现在已更新到 Unity 引擎 5。游戏运行良好并且运行完美,但是,当我单击 Android 的“构建并运行”时,出现以下错误:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.PluginImporter+<GetImporters>c__AnonStoreyC.<>m__E (UnityEditor.PluginImporter imp) (at C:/buildslave/unity/build/artifacts/generated/common/editor/PluginImporterBindings.gen.cs:104)
System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1D`1[UnityEditor.PluginImporter].MoveNext ()
System.Collections.Generic.List`1[UnityEditor.PluginImporter].AddEnumerable (IEnumerable`1 enumerable) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:128)
System.Collections.Generic.List`1[UnityEditor.PluginImporter]..ctor (IEnumerable`1 collection) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:65)
System.Linq.Enumerable.ToArray[PluginImporter] (IEnumerable`1 source)
UnityEditor.PluginImporter.GetImporters (System.String platformName) (at C:/buildslave/unity/build/artifacts/generated/common/editor/PluginImporterBindings.gen.cs:103)
UnityEditor.PluginImporter.GetImporters (BuildTarget platform) (at C:/buildslave/unity/build/artifacts/generated/common/editor/PluginImporterBindings.gen.cs:111)
UnityEditor.AndroidPluginImporterExtension.CheckFileCollisions (System.String buildTargetName)
UnityEditorInternal.PluginsHelper.CheckFileCollisions (BuildTarget buildTarget) (at C:/buildslave/unity/build/Editor/Mono/Plugins/PluginsHelper.cs:25)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
Run Code Online (Sandbox Code Playgroud)
我该如何修复这个错误?
我有一个大小不断变化的图像,我想知道我应该使用哪种字体大小来适应动态变化的大小。
如您所知,有一种Graphics.MeasureString方法可以计算字符串的大小。一种可能的方法是测量每个字体大小,直到找到最合适的字体大小,但由于我需要在一秒钟内渲染很多帧,因此性能影响太大了。
给定特定的图像宽度,是否有更有效的方法来查找字体大小?
从 ASP.NET Core 3.1 升级到版本 5 后,context.User.Claims为空
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, MyRequirement requirement)
Run Code Online (Sandbox Code Playgroud)
在
public class MyRequirementHandler : AuthorizationHandler<MyRequirement>
Run Code Online (Sandbox Code Playgroud)
我将Authorization标头与 JWT 的不记名令牌一起使用。在查看时我可以看到标头设置正确HttpContext.Request.Headers,但它似乎没有被解析。
这是在具有该属性的 Grpc 服务上设置的[Authorize]。
使用 ASP.NET Core 3.1,它运行得很好。我阅读了官方迁移指南,但他们有关授权的参考仅适用于 Azure Active Directory。
我正在使用 IdentityServer4,它托管在 ASP.NET Core 应用程序中作为中间件 ( app.UseIdentityServer();)
我忘记修改什么以使 ASP.NET Core 正确解析授权标头?
更新:
我更详细地检查了它,发现它失败了,因为它无法验证受众 ( aud) - 是的,在新创建的代币上,受众缺失(旧代币有受众)。我还注意到我添加了一个自定义范围
public override async Task GetProfileDataAsync(ProfileDataRequestContext context)
Run Code Online (Sandbox Code Playgroud)
在我的习惯里面
public class ProfileService : ProfileService<ApplicationUser>
Run Code Online (Sandbox Code Playgroud)
更新后也不见了。IdentityServer 的配置方式如下:
protected override Task HandleRequirementAsync(AuthorizationHandlerContext …Run Code Online (Sandbox Code Playgroud) asp.net-authorization jwt asp.net-core identityserver4 asp.net-core-5.0
我在将一些 API 调用包装在不同的 NuGet 包中时遇到了问题。
由于我最近发现的包,API 返回的所有错误都使用ProblemDetails/ValidationProblemDetails类Hellang.Middleware.ProblemDetails。
现在的问题是:将 API 包装器 NuGet 包添加到我的客户端应用程序时,我不想将反序列化任务留给response.Content它们(调用成功与否)。
这将主要产生 3 种响应类型:
Success=>Expected常规对象,可以针对 API 公开的每个方法进行更改BadRequest => ValidationProblemDetailsProblemDetails我在包装器中处理反序列化的主要问题是ProblemDetails/ValidationProblemDetails类“深深地”植根于Microsoft.AspNet.Mvc.Core命名空间,因此在相应的 NuGet 包中(我知道没有抽象)。
在我看来,将这样的包包含为对简单 API 包装器的直接依赖似乎有些过分(但我这样想可能是错误的,请随时纠正我)。
不幸的是,根据https://github.com/dotnet/aspnetcore/issues/7679,情况不会很快改变。
我曾想过制作我自己的 NuGet 包,包括这些类,并将其作为分布在我所有包装器中的依赖项,但我不太喜欢这个解决方案。
如果有人有更好的想法或解决方案来处理这个问题(ProblemDetails直接从 API 包装器返回一个合适的对象),他们非常受欢迎。
假设我有一个非常大的源代码,并且打算rdx在执行期间完全不使用寄存器,即,在生成汇编代码时,我只想通知我的编译器(GCC)它根本不应该使用rdx。
注意:注册rdx只是一个例子。我可以使用任何可用的 Intel x86 寄存器。
我什至很高兴更新编译器的源代码并使用我的自定义 GCC。但是需要对源代码进行哪些更改?
我尽可能地遵循 AzureAD aspnetcore 示例,尝试在我们的 aspnetcore 2.2 webapp 中实现 Azure AD 身份验证。我可以使用 Azure AD 成功登录。但是,登录后不会显示用户名。
https://github.com/Azure-Samples/active-directory-b2c-dotnetcore-webapp
该值应该从 User.Identity.Name 属性的视图中读取。
在进一步检查中,我可以看到主要索赔已正确返回到应用程序。但是,由于某种原因 HttpContext.User 对象未正确填充。我不知道为什么会这样。当我从上面的示例中查看相同的值时,HttpContext 设置正确。为了澄清起见,我已经实现了 OnSecurityTokenValidated 处理程序并使用了以下上下文:
可以看出, userPrincipal 具有预期的声明。
但是,httpContext 没有声明。因此 User.Identity.Name 也为空:
我试图进行手动登录,但这也不起作用:
private async Task SignInUser(TokenValidatedContext tokenValidatedContext)
{
var httpContext = tokenValidatedContext.HttpContext;
var userPrincipal = tokenValidatedContext.Principal;
await httpContext.SignOutAsync(AppSettings.CookieName);
await httpContext.SignInAsync(AppSettings.CookieName, userPrincipal,
new AuthenticationProperties
{
ExpiresUtc = DateTime.UtcNow.AddDays(1),
IsPersistent = false,
AllowRefresh = false
});
}
Run Code Online (Sandbox Code Playgroud)
更新
我正在设置 NameClaimType,如上所示。NameClaimType 在配置中设置
任何人都知道我做错了什么?
我正在使用 Visual Studio 2017 和 aspnetcore 2.2 库。我已将 Microsoft.Identity.Client 升级到 …
c# httpcontext claims-based-identity azure-ad-b2c asp.net-core
我刚刚将当前项目升级到新发布的 .NET Standard 2.1 和 C# 8.0,并决定将一些大型switch语句转换为新的、更紧凑的表达式语法。
由于返回的值在某些计算中进一步使用,我想知道switch当输入变量位于运算符旁边时新表达式的行为如何。
以下面的字符串连接为例:
string input = Console.ReadLine();
string output = "Letter: " + input switch
{
"1" => "a",
"2" => "b",
_ => "else"
};
Console.WriteLine(output);
Run Code Online (Sandbox Code Playgroud)
我猜想它switch与变量的绑定非常强烈input,因此首先被评估。事实上,Letter: a当我输入时,会打印出这样的内容1。
但我现在的问题是:这种行为是否适用于任何运营商?
从我的实验中,我无法确定上述假设不成立的情况,但这显然并不意味着我没有错过任何情况。该文档似乎也没有提到switch表达式上下文中的运算符优先级。还是我这里有更深层次的误解?
c# operator-precedence switch-statement c#-8.0 switch-expression
我有一个 .NET Core 解决方案,它使用 .NET Core 3.1 在 Azure Devops 上使用管道运行良好。在管道上一切正常。
从 .NET Core 3.1 迁移到 .NET 5.0 后,我开始在运行管道时遇到一些奇怪的问题,尤其是 Nuget 包。
我可以毫无问题地进行构建,但是当它开始使用 Nuget Package 进行打包时,出现了以下错误:
[错误] nuget 命令失败,退出代码 (1)
NU1202:包 Microsoft.EntityFrameworkCore 5.0.0 与 net50 (.NETFramework,Version=v5.0) 不兼容。包 Microsoft.EntityFrameworkCore 5.0.0 支持:netstandard2.1 (.NETStandard,Version=v2.1)
一些奇怪的事实是这个解决方案在本地机器上运行良好。
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.8.8.9</Version>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Run Code Online (Sandbox Code Playgroud)
我已经尝试更改 Build 上的操作系统,但出现此错误:
MSBuild 的当前可用版本是 16.7.0.37604。将 global.json 中指定的 .NET Core SDK 更改为需要当前可用的 MSBuild 版本的旧版本。
有人有想法吗?
nuget nuget-package-restore azure-devops .net-5 asp.net-core-5.0
我想知道解析 ELF 文件时.shstrtab与 a 相比如何识别a ?.strtab从阅读elf(5) - Linux 手册页来看,两者都是节标题类型SHT_STRTAB,那么我如何知道我遇到的是其中之一呢?
他们的描述是:
.shstrtab
This section holds section names. This section is of type
SHT_STRTAB. No attribute types are used.
Run Code Online (Sandbox Code Playgroud)
.strtab
This section holds strings, most commonly the strings that
represent the names associated with symbol table entries. If
the file has a loadable segment that includes the symbol
string table, the section's attributes will include the
SHF_ALLOC bit. Otherwise, the bit will be off. …Run Code Online (Sandbox Code Playgroud) 我创建了代码的简化版本来演示我遇到的问题。我有一个自定义 Blazor 组件 TestComponent.razor:
@{ int index = 0; }
@foreach (var option in _value)
{
<input id="@index" type="checkbox" @bind="@option.Selected" /><label for="@index">@option.Name</label>
index++;
}
@code {
[Parameter] public EventCallback<TestModel[]> ValueChanged { get; set; }
private TestModel[] _value;
[Parameter] public TestModel[] Value
{
get => _value;
set
{
if (_value == value) return;
_value = value;
ValueChanged.InvokeAsync(value);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个基本模型 TestModel.cs:
public class TestModel
{
public string Name { get; set; }
public bool Selected { get; set; }
} …Run Code Online (Sandbox Code Playgroud) c# ×5
asp.net-core ×3
linux ×2
nuget ×2
.net ×1
.net-5 ×1
api ×1
azure-ad-b2c ×1
azure-devops ×1
blazor ×1
c#-8.0 ×1
elf ×1
gcc ×1
gdi+ ×1
httpcontext ×1
jwt ×1
string-table ×1