user3363744
user3363744

Reputation: 169

Why cant I use the Windows Name space in WPF app but I can use it in a Universal app

why am I able to use the Windows Namespace in windows universal application

For example using Windows.Networking.Sockets; using Windows.Storage.Streams;

But I cant use it in WPF?

I get red lines under Networking and Storage saying that the reference does not exist.

One fix I googled said to add the PresentationFramework as a reference. Only problem is, I see PresentationFramework in the reference folder.

Thank you

Upvotes: 0

Views: 689

Answers (1)

Dai
Dai

Reputation: 155433

The .NET framework base class library is in a bit of a mess as there are different implementations, all from Microsoft, all with their own differences (historically there was the "Full Fat" Framework, the Client-Profile Framework, the Compact Framework and the Micro Framework for embedded devices, XNA for Xbox 360 and then Silverlight had its own version too).

Windows 8 added the Metro/Modern/"Store App" platform which is its own version of .NET with a slightly different, Twilight Zone-different, base class library known as the "Windows Runtime". This library which provides many of the types previously seen in the System namespace now under the Windows namespace. Windows 10 renamed the platform to "Universal Apps".

For more information see here: https://msdn.microsoft.com/en-us/library/br230302.aspx. Frustratingly, Microsoft recommends:

Typically, you do not simply convert an existing .NET Framework app to a Windows 8.x Store app; you redesign the .NET Framework app for the new user experience

For the user-interface layer, that sounds reasonable (as the Universal Platform has its own UX framework based on XAML, which is similar, but not identical, to WPF) - however the platform also requires you to modify all library code written against .NET to use the Windows namespace for IO, which places a significant burden on the developer - especially if they're using a third-party library they don't have source-code access to.

Upvotes: 2

Related Questions