Skip to content

CsWinRT Projection Assembly throws Activation error #144

@KenAdamson

Description

@KenAdamson

When attempting to instantiate a Microsoft.WinRTC.WebRtcWrapper.rtc.Thread, the WinRT.BaseActivationFactory throws an TargetInvocationException - Class not registered.

Steps to reproduce the behavior:

  1. Create C# projection assembly (in order to get it to compile, you must use Microsoft.Windows.CsWinRT 1.3.5) - expose the following namespaces:
		<CsWinRTIncludes>
			Microsoft.WinRTC.WebRtcWrapper.webrtc;
			Microsoft.WinRTC.WebRtcWrapper.rtc;
			Microsoft.WinRTC.WebRtcWrapper.rtc.factory_implementation;
			Microsoft.WinRTC.WebRtcWrapper.cricket;
			Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection;
			Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnectionFactory;
			Microsoft.WinRTC.WebRtcWrapper.webrtc.VideoFrame;
			webrtc
		</CsWinRTIncludes>

The nuspec for this project contains the following dependencies:

		<dependencies>
			<group targetFramework="net6.0-windows10.0.19041.0" />
			<group targetFramework=".NETCoreApp3.0" />
			<group targetFramework="UAP10.0" />
			<group targetFramework=".NETFramework4.6" />
		</dependencies>
  1. Create a Console App which references the nuget package via local repository
  2. In Program.cs, paste the following (adapted from the XAML component in the samples):
using Microsoft.WinRTC.WebRtcWrapper.webrtc;
using Microsoft.WinRTC.WebRtcWrapper.webrtc.PeerConnection;

var networkThread = Microsoft.WinRTC.WebRtcWrapper.rtc.Thread.CreateWithSocketServer();
networkThread.Name = "pc_network_thread";
networkThread.Start();

var workerThread = Microsoft.WinRTC.WebRtcWrapper.rtc.Thread.Create();
workerThread.Name = "pc_worker_thread";
workerThread.Start();

var signalingThread = Microsoft.WinRTC.WebRtcWrapper.rtc.Thread.Create();
signalingThread.Name = "pc_signaling_thread";
signalingThread.Start();

var audioEncoderFactory = WebRTC.CreateBuiltinAudioEncoderFactory();
var audioDecoderFactory = WebRTC.CreateBuiltinAudioDecoderFactory();
var videoDecoderFactory = WebRTC.CreateBuiltinVideoDecoderFactory();
var videoEncoderFactory = WebRTC.CreateBuiltinVideoEncoderFactory();

var peerConnectionFactory = new PeerConnectionFactory(networkThread,
    workerThread,
    signalingThread,
    audioEncoderFactory,
    audioDecoderFactory,
    videoEncoderFactory,
    videoDecoderFactory);

var config = new RTCConfiguration
{
    SdpSemantics = SdpSemantics.UnifiedPlan
};
// populate ice servers via (maybe) a signaling call
var iceServer = new IceServer
{
    Urls = new List<string> { "stun:stun.l.google.com:19302" }
};
config.IceServers.Add(iceServer);

var peerConnectionObserver = new PeerConnectionObserver();
peerConnectionObserver.OnIceCandidate += Console.WriteLine;

var peerConnectionDependencies = new PeerConnectionDependencies(peerConnectionObserver);

var peerConnection = peerConnectionFactory.CreatePeerConnection(config, peerConnectionDependencies);

Console.WriteLine(peerConnection);

  1. Run, observe error

Expected behavior
Thread class is constructed without throwing COM Activation error.

Screenshots

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser N/A
  • Version [e.g. 22]

Smartphone (please complete the following information):
N/A

stacktrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions