Namespace Media does not exist

I am developing in Unity 4.7.1f1 using Visual Studio 2015 C# on Windows 8. I’m trying to do some bitmap processing using the [Kinect background removal tool] (GitHub - Vangos/kinect-2-background-removal: Background removal (aka "green-screen effect") using Kinect for Windows version 2.). The class starts with these lines:

using System.Windows.Media;

using System.Windows.Media.Imaging;

This produce the following error:

The type or namespace name ‘Media’ does not exist in the namespace ‘Windows’ (are you missing an assembly reference?)

I need this for types PixelFormat, WritableBitmap, andInt32Rect.

My reading, including searches through Unity Answers and Stack Overflow, has indicated the following:

  • Adding the assembly in Visual Studio will not have it compile properly. Unity needs to have it added in Unity/Mono.
  • This component of Windows is in PresentationCore.dll which you can copy to the project.

I tried the following solutions:

  • I copied the PresentationCore.dll file from Program Files\Reference Assemblies\Microsoft\Framework\.NetFramework\v4.0\Profile to the Assets folder by dragging it to the ‘Project’ pane’s Assets folder.

  • I copied the PresentationCore.dll file from a subfolder of \Windows\WinSxS to the Assets folder by dragging it to the ‘Project’ pane’s Assets folder.

  • I checked I was building for .NET 2.0 and not a subset.

None of this cleared the error. I would restart Unity and load the files in Visual Studios when making a change. How to I get Mono to use accept reference to it? Am I missing something very simple? Like a step after I copy the DLL to the assets folder?

Check this and scroll down to “Step by Step Guide for MonoDevelop and Visual Studio”. A bit further down you can see how to correctly add the assembly reference.