Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting an error trying to use System namespace in xaml

I get the following error trying to use the String type in xaml:

XLS0419 Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'System' that could not be found.

Here is the code:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:markup="clr-namespace:MahApps.Metro.Markup;assembly=MahApps.Metro"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
                    xmlns:system="clr-namespace:System;assembly=mscorlib"
                    mc:Ignorable="options">

    <!--  Matadata  -->
    <system:String x:Key="Theme.Name">Dark.Blue</system:String>

The line 'xmlns:system="clr-namespace:System;assembly=mscorlib"' is the location of the error. I have simply copied this code from another file in another project in the solution, and the code works fine there. I have no idea how to resolve this.

I have tried shutting down Visual Studio and restarting the computer.

like image 352
L Fitz Avatar asked Sep 19 '25 00:09

L Fitz


1 Answers

Your markup should compile just fine on both .NET Framework and .NET Core but if you target the latter and have issues with squiggly lines in Visual Studio, you could change the namespace declaration to this:

xmlns:system="clr-namespace:System;assembly=System.Runtime"
like image 61
mm8 Avatar answered Sep 20 '25 13:09

mm8