[英]Running MRTK2 project gives “ Failed to resolve System.Reflection.BindingFlags”
我正在尝试将我的项目从Unity 2017 LTS移植到2018 LTS和MRTK2。 一切都进行得很顺利,直到我尝试在HoloLens 1仿真器上运行该项目。
我收到以下错误:
1> System.Exception: Failed to resolve System.Reflection.BindingFlags
1> at Unity.ModuleContext.Retarget(TypeReference type, GenericContext context)
1> at Unity.ModuleContext.Retarget(MethodReference method, GenericContext context)
1> at Unity.FixReferencesStep.Visit(MethodDefinition method, GenericContext context)
1> at Unity.FixReferencesStep.Visit(TypeDefinition type)
1> at Unity.TypeDefinitionDispatcher.DispatchType(TypeDefinition type)
1> at Unity.TypeDefinitionDispatcher.DispatchType(TypeDefinition type)
1> at Unity.TypeDefinitionDispatcher..ctor(ModuleDefinition module, ITypeDefinitionVisitor visitor)
1> at Unity.FixReferencesStep.ProcessModule()
1> at Unity.ModuleStep.Execute()
1> at Unity.FixReferencesStep.Execute()
1> at Unity.Step.Execute(OperationContext operationContext, IStepContext previousStepContext)
1> at Unity.Operation.Execute()
1> at Unity.Program.Main(String[] args)
搜索此错误没有给我任何帮助,我还没有更改Unity构建的项目。 我正在Debug
和x86
运行它。 我正在通过普通的Unity Build窗口进行构建。
使用Minimum Platform Version 10.0.17134.0
和Target SDK Version 10.0.18362.0
新的空Unity项目也会发生这种情况,构建示例也会出现此错误。
我遇到了类似的问题,并且要解决此问题,我将其更改为il2cpp后端。
意识到这可能不仅仅是我,我在MRTK github中提交了一个问题 。 事实证明,这是Visual Studio中的错误,他们正在与Microsoft一起解决它。
有两种解决方法 ,要么将Windows版本15063定位为最低版本,要么更改yourpoject .csproj。
如果您不想更改最低版本,请执行以下步骤:
在文本编辑器中打开yourproject .csproj
查找行<Target Name="BeforeResolveReferences" Condition="'$(BuildingProject)' == 'true'">
用。。。来代替:
<UsingTask TaskName="FixProjectJson" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\\Microsoft.Build.Tasks.Core.dll"> <ParameterGroup /> <Task> <Using Namespace="System" /> <Using Namespace="System.IO" /> <Code Type="Fragment" Language="cs"> <![CDATA[File.WriteAllText("project.lock.json", File.ReadAllText("project.lock.json").Replace("ref/netstandard1.5/System.Reflection.TypeExtensions.dll", "ref/netstandard1.3/System.Reflection.TypeExtensions.dll"));]]> </Code> </Task> </UsingTask> <Target Name="BeforeResolveReferences" Condition="'$(BuildingProject)' == 'true'">
找到这行<Message Importance="high" Text="Running AssemblyConverter..." />
用。。。来代替:
<Message Importance="high" Text="Running AssemblyConverter..." /> <FixProjectJson />
完成此操作后,我的项目最终得以编译,并且能够在HoloLens 2 Emulator中运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.