I am trying to use Win2D in a desktop application. Project is building but i get a runtime error "Requested Windows Runtime type 'Microsoft.Graphics.Canvas.CanvasDevice' is not registered"
I know that in order to include Win2D i need to add the reference to the application's manifest file, which i have done.
The code:
private void CaptureMSFSScreen()
{
process = Process.GetProcesses().Where(p => p.ProcessName == "xxxxxxxx").Single();
hwnd = process.MainWindowHandle;
canvasDevice = new CanvasDevice();
GraphicsCaptureItem item = CaptureHelper.CreateItemForWindow(hwnd);
framePool = Direct3D11CaptureFramePool.Create(canvasDevice, DirectXPixelFormat.B8G8R8A8UIntNormalized, 1, item.Size);
session = framePool.CreateCaptureSession(item);
framePool.FrameArrived += (s, a) =>
{
using (var frame = framePool.TryGetNextFrame())
{
ProcessFrame(frame);
}
};
item.Closed += (s, a) =>
{
StopCapture();
};
}
The manifest file has this section inside:
<file name="Microsoft.Graphics.Canvas.dll">
<activatableClass
name="Microsoft.Graphics.Canvas.CanvasDevice"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass name="Microsoft.Graphics.Canvas.UI.Composition.CanvasComposition"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass
name="Microsoft.Graphics.Canvas.Effects.SaturationEffect"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass
name="Microsoft.Graphics.Canvas.Effects.BlendEffect"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass
name="Microsoft.Graphics.Canvas.Effects.GaussianBlurEffect"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass
name="Microsoft.Graphics.Canvas.Effects.ColorSourceEffect"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass
name="Microsoft.Graphics.Canvas.Effects.CompositeEffect"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass
name="Microsoft.Graphics.Canvas.Effects.OpacityEffect"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass
name="Microsoft.Graphics.Canvas.CanvasBitmap"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
<activatableClass
name="Microsoft.Graphics.Canvas.Effects.BorderEffect"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1"/>
</file>