MixedReality-WebRTC icon indicating copy to clipboard operation
MixedReality-WebRTC copied to clipboard

Dependency to mrwebrtc.dll not working properly for .Net Framework 4.6.2

Open mothermetabot opened this issue 4 years ago • 6 comments

Describe the bug Consuming the MixedReality.WebRTC library throws an error:

Unable to load DLL 'mrwebrtc': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

To Reproduce Steps to reproduce the behavior:

  1. Create WPF project. (.Net Framework 4.6.2)
  2. Add any code consuming the library (e.g. var deviceList = await DeviceVideoTrackSource.GetCaptureDevicesAsync();)
  3. Build and Run

Expected behavior The code is supposed to execute without errors.

Environment

  • MR-WebRTC version : last stable version 2.0.0
  • Platform: Windows Desktop, OS Windows 10, WPF
  • Architecture: x86
  • Target device: Windows Desktop

Additional context I installed the Nuget package through Visual Studio 2019 Community. The project builds but fails immediately when I call a function from the WebRTC API. I cannot find any mrwebrtc.dll in the bin folder, is this normal behavior(see Exception Message above)? In the Solution Explorer, I can see Microsoft.MixedReality.WebRTC library under References and the respective DLL in the bin folder.

StackTrace:

   at Microsoft.MixedReality.WebRTC.Interop.DeviceVideoTrackSourceInterop.EnumVideoCaptureDevicesAsync(VideoCaptureDeviceEnumCallback enumCallback, IntPtr userData, VideoCaptureDeviceEnumCompletedCallback completedCallback, IntPtr completedUserData)
   at Microsoft.MixedReality.WebRTC.DeviceVideoTrackSource.<>c.<GetCaptureDevicesAsync>b__2_0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at SDHub.Gui.CallApp.CallView.<Button_Click>d__7.MoveNext() in C:\Users\esguio\Documents\Projects\SDHub\SDHub.Gui.CallApp\CallView.xaml.cs:line 52
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at SDHub.Gui.CallApp.App.Main()

mothermetabot avatar Aug 12 '20 16:08 mothermetabot

@mothermetabot I downloaded the NuGet package manually and I confirm that mrwebrtc.dll is in runtimes\win10-x86\native, so should be automatically deployed. I am not sure why it is not. Can you please confirm by manually copying the DLL next to your executable, to see if that solves things?

@efsjouw the bug report mentions x86 Desktop.

djee-ms avatar Aug 24 '20 16:08 djee-ms

System.DllNotFoundException: mrwebrtc assembly: type: member:(null) at Microsoft.MixedReality.WebRTC.DeviceVideoTrackSource.<>c.<GetCaptureDevicesAsync>b__2_0() at System.Threading.Tasks.Task1[[System.Collections.Generic.IReadOnlyList1[[Microsoft.MixedReality.WebRTC.VideoCaptureDevice, Microsoft.MixedReality.WebRTC, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()

Thanks for your work.

I have already tried to use it several times, but bumped into mrwebrtc.dll Could you tell me where dll is looking for?

parad74 avatar Sep 06 '20 13:09 parad74

This is the general Windows rule of LoadLibrary(), which is invoked automatically by P/Invoke. Generally this means mrwebrtc.dll needs to be in the same folder as Microsoft.MixedReality.WebRTC.dll (the C# assembly).

djee-ms avatar Sep 07 '20 08:09 djee-ms

Is there any possibility of using this for .net core web applications hosted on Linux platforms?

srinath999 avatar Apr 10 '21 18:04 srinath999

This is the general Windows rule of LoadLibrary(), which is invoked automatically by P/Invoke. Generally this means mrwebrtc.dll needs to be in the same folder as Microsoft.MixedReality.WebRTC.dll (the C# assembly).

I think this fixes the issue. I I copied Microsoft.MixedReality.WebRTC.2.0.2\runtimes\win10-x86\native\mrwebrtc.dll to the build output directory. It works for me

HaleXie avatar Dec 05 '21 05:12 HaleXie

By default a console App will have a 'Any CPU' configuration. This confuses the package manager because it has x86 & x64 runtimes so doesn't copy over the runtime correctly. If you create a new configuration, say x64, then it should automatically work.

paulio avatar Jan 30 '22 12:01 paulio