dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.1k stars 1.17k forks source link

Crash When Oculus Rift S is connected #9706

Open jacobh12349 opened 2 months ago

jacobh12349 commented 2 months ago

My wpf app isn't used for vr, but when I open a wpf app while my oculus rift s vr headset is connected to my computer, the wpf app crashes with this exception message, I think the wpf app is thinking the oculus rift controllers are a stylus, and it crashes because of that for some reason.

Exception thrown: 'System.InvalidCastException' in PresentationCore.dll
System.InvalidCastException: Interface not registered

   at MS.Win32.Penimc.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
   at MS.Win32.Penimc.UnsafeNativeMethods.CreatePimcManager()
   at System.Environment.get_StackTrace()
   at MS.Win32.Penimc.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
   at MS.Win32.Penimc.UnsafeNativeMethods.CreatePimcManager()
   at MS.Win32.Penimc.UnsafeNativeMethods.get_PimcManager()
   at System.Windows.Input.PenThreadWorker.WorkerOperationGetTabletsInfo.OnDoWork()
   at System.Windows.Input.PenThreadWorker.WorkerOperation.DoWork()
   at System.Windows.Input.PenThreadWorker.ThreadProc()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
jacobh12349 commented 2 months ago

I'm on the latest version of wpf too

lindexi commented 2 months ago

@jacobh12349 Could you try enable the WMPOINTER by the code:

        public App()
        {
            AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);
        }
lindexi commented 2 months ago

From your message at MS.Win32.Penimc.UnsafeNativeMethods.CreatePimcManager(), I can know it can not find the PenImc COM in your drives.

And the PenImc can be bypassed by enable the WMPOINTER message.

jacobh12349 commented 2 months ago
AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);

I don't want my app to support the rift controllers though, i just have my wpf app running in the background.

jacobh12349 commented 2 months ago

i also dont have any styluses