简体   繁体   English

Hololens 2 和 Microsoft.MixedReality.QR 缺少方法异常

[英]Missing method exception with Hololens 2 and Microsoft.MixedReality.QR

I'm trying to scan QR codes with Hololens 2 by creating a unity project, building the unity project and then deploying the solution that unity generates.我正在尝试通过创建一个统一项目、构建统一项目然后部署统一生成的解决方案来使用 Hololens 2 扫描 QR 码。

I've tried following this guide: https://localjoost.github.io/Reading-QR-codes-with-an-MRTK2-Extension-Service/我已经尝试遵循本指南: https://localjoost.github.io/Reading-QR-codes-with-an-MRTK2-Extension-Service/

Whenever any of the code runs for Microsoft.MixedReality.QR runs, I get a missing method exception for System.RuntimeType::GetGUID(System.Type, System.Byte[])每当运行 Microsoft.MixedReality.QR 的任何代码时,我都会收到 System.RuntimeType::GetGUID(System.Type, System.Byte[]) 的缺失方法异常

The exception happens even if I just check whether scanning for QR codes is supported with the following line:即使我只检查以下行是否支持扫描二维码,也会发生异常:

QRCodeWatcher.IsSupported();

The stack trace looks a bit like this:堆栈跟踪看起来有点像这样:

System.Reflection.TragetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException:
System.RuntimeType::GetGUID(System.Type, System.Byte[])
    at System.RuntimeType.get_GUID() [0x00000] in <00000000000000000000>:0
    at WinRT.IObjectReference.As[T]()[0x00000] in <00000000000000000000>:0
    at WinRT.ActivationFactory`1[T].As[I]() [0x00000] in <00000000000000000000>:0
    at Microsoft.MixedReality.QR.QRCodeWatcher+Statics..ctor()[0x000000] in <00000000000000000000>:0

If it helps, I'm using Windows SDK 10.0.19041.0 and Unity 2021.2.3f1如果有帮助,我正在使用 Windows SDK 10.0.19041.0 和 Unity 2021.2.3f1

No idea about hololens, but...不知道hololens,但是...

I've seen this many times due to there being different versions of the assemblies being used/expected.由于正在使用/预期的程序集版本不同,我已经多次看到这种情况。

Some higher level code it trying to find a method via reflection, but the installed assembly (at least the one being discovered) is of a version that does not have that method.一些更高级别的代码试图通过反射找到一种方法,但安装的程序集(至少是被发现的)是没有该方法的版本。 (this will always be a problem with reflection based "binding"). (这将始终是基于反射的“绑定”的问题)。

So, check that all the versions are compatible.因此,请检查所有版本是否兼容。

If you've recently upgraded some part, it's possible that VS/msbuild has left some old version lying around.如果您最近升级了某些部分,则 VS/msbuild 可能会留下一些旧版本。 (It "caches" dll's under the obj folders as a build optimisation. But sometime trips up over recognising that something needs updating). (它“缓存”了 obj 文件夹下的 dll 作为构建优化。但有时会因为识别出需要更新的东西而绊倒)。

In powershell, try ls -include obj,bin -recurse | rm -recurse -force在 powershell 中,尝试ls -include obj,bin -recurse | rm -recurse -force ls -include obj,bin -recurse | rm -recurse -force from the root of your solution folder. ls -include obj,bin -recurse | rm -recurse -force从您的解决方案文件夹的根目录。 This will delete all "bin" and "obj" folders under your solution.这将删除您的解决方案下的所有“bin”和“obj”文件夹。 Then rebuild.然后重建。

It's a big ugly stick but This has often worked for me in these situations.这是一个丑陋的大棒,但这在这些情况下经常对我有用。

I have cloned the sample provided by the guide;我已经克隆了指南提供的样本; it works fine(with Unity2019.4.33f1).它工作正常(使用 Unity2019.4.33f1)。 I noticed this guide sets the project XR pipelines as Legacy XR, and Legacy XR is deprecated in Unity 2019 and removed in Unity 2020, you should roll back your Unity to 2019 LTS: https://unity3d.com/unity/qa/lts-releases?version=2019.4我注意到本指南将项目 XR 管道设置为 Legacy XR,并且 Legacy XR 在 Unity 2019 中已弃用并在 Unity 2020 中删除,您应该将 Unity 回滚到 2019 LTS: https://unity3d.com/unity/qa/lts -releases?version=2019.4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM