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

mrwebrtc assembly not found in Xamarin.Forms

Open chauhan19911 opened this issue 5 years ago • 3 comments

I'm trying to create mobile based video surveillance app, where host (sender) is in win form (core) application. Previously I have create client (recover) in win form (core) which is working fine, but same code is giving exception in Xamarin.Forms in both Android and iOS.

Initialize Peer Connection (Working fine)

_peerConnection.InitializeAsync(new PeerConnectionConfiguration()).ContinueWith((t) =>
{
  _peerConnection.LocalSdpReadytoSend += _peerConnection_LocalSdpReadytoSend;
});

On Web Socket Message Received (Giving exception)

_peerConnection.SetRemoteDescriptionAsync(new SdpMessage
{
     Content = obj["offer"],
     Type = SdpMessageType.Offer
}).ContinueWith((t) => {
     if (_peerConnection.CreateAnswer()) {
     }
});

Getting exception in SetRemoteDescriptionAsync method

{System.DllNotFoundException: mrwebrtc assembly: type: member:(null) at (wrapper managed-to-native) Microsoft.MixedReality.WebRTC.Interop.PeerConnectionInterop.PeerConnection_SetRemoteDescriptionAsync(Microsoft.MixedReality.WebRTC.Interop.PeerConnectionHandle,Microsoft.MixedReality.WebRTC.SdpMessageType,string,Microsoft.MixedReality.WebRTC.Interop.PeerConnectionInterop/PeerConnectionRemoteDescriptionAppliedDelegate,intptr) at Microsoft.MixedReality.WebRTC.Interop.PeerConnectionInterop.SetRemoteDescriptionAsync (Microsoft.MixedReality.WebRTC.Interop.PeerConnectionHandle peerHandle, Microsoft.MixedReality.WebRTC.SdpMessageType type, System.String sdp) [0x0002a] in <365850aabc5b4712b4c17093dcf80925>:0 at Microsoft.MixedReality.WebRTC.PeerConnection.SetRemoteDescriptionAsync (Microsoft.MixedReality.WebRTC.SdpMessage message) [0x0002a] in <365850aabc5b4712b4c17093dcf80925>:0 at WebRTC.MainPage._webSocket_OnMessage (System.Object sender, WebSocketSharp.MessageEventArgs e) [0x003bf] in D:\Projects\POC\WebRTC\WebRTC\WebRTC\MainPage.xaml.cs:96 }

chauhan19911 avatar Feb 16 '21 15:02 chauhan19911

As the error indicates, mrwebrtc.dll was not deployed correctly. Might be related to #634, since this was fixed but we didn't respin any new NuGet packages with that fix.

Best way to find out is try copying the DLL manually and see if that solves the issue. If it does then it's a deployment issue. If it doesn't then that's a more complex issue where the DLL is possibly missing dependencies so cannot load. Some tools like https://github.com/lucasg/Dependencies might help figuring out which DLL is missing.

jehumb-havok avatar Feb 16 '21 17:02 jehumb-havok

@djee-ms, thanks for replying, If this is missing dll issue then how Peer Connection getting initialize?

_peerConnection.InitializeAsync(new PeerConnectionConfiguration()).ContinueWith((t) =>
{
  _peerConnection.LocalSdpReadytoSend += _peerConnection_LocalSdpReadytoSend;
});

Above code is not giving any exception but while SetRemoteDescriptionAsync I'm getting DllNotFoundException: mrwebrtc

I have tried manually putting putting dll's, but that also didn't help

After checking project I got this: // Note that on Windows due to a "bug" in LoadLibraryEx() this filename must not contain any '.'. // See https://github.com/dotnet/runtime/issues/7223 internal const string dllPath = "mrwebrtc";

chauhan19911 avatar Feb 17 '21 05:02 chauhan19911

Sorry I missed some part:

same code is giving exception in Xamarin.Forms in both Android and iOS.

Android is only supported via Unity, not via the direct C# .NET Core library, and iOS is not supported at all. So this was never tested, and I have no idea how Xamarin works with regard to DllImport, nor what is happening here.

We can continue to discuss about this issue but I am tagging it as Invalid because this is outside of the scope of supported platforms. I also have no knowledge about Xamarin so I doubt I can be of any help.

jehumb-havok avatar Feb 17 '21 09:02 jehumb-havok