Encountered a problem recently when working with WPF, XAML, and C# in Visual Studio 2017. I lost a lot of time over it while scratching my head in confusion, but I found the problem at the solution.
It was somewhat self-inflicted, but it didn't necessarily help that the error being presented indicated nothing about where it was coming from!
If you are manually editing your project file so that you can integrate Windows 10 OS features with your desktop application, it's likely because you were reading this MSDN article.
Desktop C# applications can reference WinRT run-time libraries that are available as part of the Windows 10 SDK. I was recently working on a project that required references to those libraries, so that I could integrate a Windows 10 feature with my application.
This required me to modify my project file (.csproj) so that it contained the following XML elements.
<PropertyGroup> ... <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> <TargetPlatformVersion>10</TargetPlatformVersion> ... </PropertyGroup>
The problem here is that "TargetPlatformVersion" is considered to be malformed. The version string specified is too short, or doesn't contain sufficient information such as the minor revision or build number.
Should you open the XAML designer after modifying the project manually with the property value above, you are going to encounter this mysterious and useless error.
Simply modify your .csproj file so that it specifies the exact version of the Windows 10 SDK that you are intending on using. Unfortunately when you open the XAML designer, there is no indication where the error is coming from exactly. Seemingly the XAML designer is disconnected from the Windows 10 SDK that is being referenced by the project.
<PropertyGroup> ... <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> <TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion> ... </PropertyGroup>