2

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.

user9236834
  • 153
  • 10

1 Answers1

0

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.

Peter Torr - MSFT
  • 11,824
  • 3
  • 18
  • 51
  • I don't know how to solve this problem, though, because this project definitely has to built for UWP for us to deploy the app to multiple systems. Using Desktop Bridge alone isn't enough for our needs, even though for now I can start off with using a Visual C# or .NET console application. – user9236834 Jan 29 '18 at 14:33
  • Hang on, I saw this example last week. But for the kind of project I'm trying to work on, it seems outdated. https://github.com/neutmute/emgucv/tree/master/Emgu.CV.Example/RealtimeCamera.UWP – user9236834 Jan 29 '18 at 15:01
  • Do you need to deploy on non-desktop devices? – Peter Torr - MSFT Jan 29 '18 at 17:10
  • Not right now, but eventually. I am pondering about using Unity to build the example application I'm working on at the moment because it does support building a project to Android, iOS, and so on. It does add a layer of abstraction, though, and would probably make the project a bit hard to manage. It might be useful for the full project, however, because like OpenCV itself, the Unity API has its own UI library and ways on attaching event listeners to the interface. Is there something a bit simpler, though? – user9236834 Jan 29 '18 at 18:28
  • I even found this on integrating OpenCV directly to Unity. https://stackoverflow.com/questions/16612513/opencv-emgucv-wrapper-integration-in-unity – user9236834 Jan 29 '18 at 18:29