Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot find System.Xaml in .net 6

I created a console application with a target framework of .net 6.0 in order to write a custom Xaml writer. This is the project configuration:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

I want to extend the XamlXmlWriter class but I can’t import it. If I add using System.Xaml I get: The type or namespace Xaml does not exist in the namespace System. What am I missing?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need two changes to your project file:

  • Target net6.0-windows instead of net6.0
  • Add <UseWPF>true</UseWPF> as an additional property

As per the documentation, it looks like XamlXmlWriter is available in the Windows Desktop framework for .NET 6, but not in "general" .NET 6.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading