The type "Windows.UI.Xaml.FrameworkElement" is defined in an assembly that is not referenced

733 Views Asked by At

I have an UWP app that i'm trying to build. It all works fine in debug mode, but when i switch to release and then try to build, it shows the error

error CS0012: The type 'Windows.UI.Xaml.FrameworkElement' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.UniversalApiContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.

I've narrowd it down to the project property called "Compile with .NET Native tool chain" being the source of the problem. Atleast the project can build when i uncheck that property. I would however prefer to have the option enabled. I've added references to the Windows Desktop and Windows Mobile extensions.

Any idea of what i need to do to fix this?

3

There are 3 best solutions below

0
On BEST ANSWER

After contacting Matt, he and his colleagues discovered that it was an error in .NET Native. So i just have to wait for the next update to .NET Native.

EDIT: After the latest update to Visual Studio 2015 (update 3), I can now successfully build the app in release mode with .NET native toolchain! Huzzah!

1
On

I've had far too many problems with developing for Windows Universal. I've had problems similar to this. Re-install your Windows 10 SDK, This solved it for me!

0
On

I answered a similar question. Do you use XmlSerializer to serialize a type which references winmd type? In your case the winmd type seems to be 'Windows.UI.Xaml.FrameworkElement'? If so, please have a look at my answer for that question. It seems that .Net Native tools have problem with generating XmlSerializer for types referencing winmd types.