Home > Mobile >  Missing method exception with Hololens 2 and Microsoft.MixedReality.QR
Missing method exception with Hololens 2 and Microsoft.MixedReality.QR

Time:12-03

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.

I've tried following this guide: 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[])

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

CodePudding user response:

No idea about hololens, but...

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. (It "caches" dll's under the obj folders as a build optimisation. But sometime trips up over recognising that something needs updating).

In powershell, try ls -include obj,bin -recurse | rm -recurse -force from the root of your solution folder. This will delete all "bin" and "obj" folders under your solution. Then rebuild.

It's a big ugly stick but This has often worked for me in these situations.

CodePudding user response:

I have cloned the sample provided by the guide; it works fine(with 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

  • Related