Search code examples
c#uwpvisual-studio-2017emgucv

EmguCV and UWP - Cannot resolve Assembly or Windows Metadata file 'System.Windows.Forms.dll' (Emgu.CV.UI)


I am writing an example UWP program, that uses EmguCV (an OpenCV wrapper for programs written in VB, C#, .NET, etc.), to see if I can use it in a UWP app for a project I'm working on. I'm using Visual Studio 2017 Community and EmguCV 3.3.0.2824, which I downloaded the Windows installer and ran it on this Lenovo Thinkpad laptop with Windows 10 Enterprise x64.

For some reason, when I try to build the solution, I get these two compiler errors in this photo.

In plain text:

XamlCompiler error WMC1006: Cannot resolve Assembly or Windows Metadata file 'System.Windows.Forms.dll'

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\WindowsXaml\v15.0\8.2\Microsoft.Windows.UI.Xaml.Common.targets(354,5): Xaml Internal Error error WMC9999: Type universe cannot resolve assembly: System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.

Why do I have an Assembly conflict between Emgu.CV.UI and the UI namespace in the UWP API? What can I do to enable using both in my app?

This photo is what the Solution Explorer looks like.

In plain text: I have all the default files Visual Studio 2017 generates when I create a blank UWP application. In addition, I have a file called RTG_Demo_App.dll containing some code written in C++ that uses OpenCV. In the References group, I am referencing Emgu.CV.UI, and Emgu.CV.World.

I am using the default code App.xaml.cs has, as well as MainPage.xaml.cs, with the exception that I have the following lines:

using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.UI;

After doing some research and experimentation, the root cause I found is a conflict between the reference to Emgu.CV.UI (Emgu.CV.UI.dll), and the UI namespace in the library for the UWP. I can't remove the reference to the "Universal Windows" library because it's part of the UWP framework I need for the project.

I did do some research around, except I couldn't come across a resource to where the project involves EmguCV with scripts written in C# directly and to be built for the UWP, rather than Visual C# or .NET.

What I am trying to accomplish here is a project where OpenCV is used, the target is UWP, and the scripts are in C#. OpenCV is not supported by C#, so I'm using EmguCV instead.

Please help me out here.


Solution

  • System.Windows.Forms is not available for UWP projects since it is a wrapper around User & GDI, which are both unavailable for UWP.

    You can use a Desktop Bridge project if you only want to ship on Desktop.