Reference library targeting .NET Standard from a Windows Store app or Profile7 PCL? - windows-store-apps

The doc page says a library targeting .NET Standard can reference a "profile-based PCL". But what about the reverse? Can a Profile 7 PCL reference a library targeting .NET Standard (any version)?
Also, can a Windows Store (Windows 8.1) app reference a library that only targets .NET Standard?

Can a Profile 7 PCL reference a library targeting .NET Standard (any
version)?
You may refer to this article written by #Adam Pedly Microsoft MVP (Xamarin):
" Remember that once you have a .NET Standard Library a Profile Based PCL can’t reference it, hence you need to convert everything up the chain to .NET Standard."
Update:
Check the doc, see the complete set of .NET runtimes that support the .NET Standard Library. So if you want to reference it in Windows 8.1 project, you can target .NET Standard 1.2, which provides less functions than .NET Standard 1.6 version(e.g. no System.Net.Sockets).

Related

Using Avalonia with netstandard

I try to run my Avalonia app on .net framework. However, when I downgrade targetframework to netstandard2.0, AppBuilder becomes unavailable and I just couldn't figure out, how to fix that problem.
I couldn't find any template, that targets .net framework or netstandard. Documentation contains nothing regarding this issue. The only thing I could find is this Github issue. As I understood, AppBuilder is not supposed to be used in netstandard. Then, what is proper replacement for following code?
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI();
Edit:
As it was pointed out, netstandard can't be used as a target for Avalonia apps, but we can specify multiple targets. So I replaced
<TargetFramework>net7.0</TargetFramework>
with
<TargetFrameworks>net7.0;net48</TargetFrameworks>
And it worked on .NET core and .NET Framework
netstandard2.0 isn't an actual .NET framework version: it's a specification of the common API beteen .NET framework 4.6.1 and .NET core 2.0 (among others). As such netstandard2.0 only makes sense as the target framework for libraries, not applications.
If you want your app to target .NET framework then you need to use a .NET framework version as the target framework, for example net48 for .NET Framework 4.8.

Xml serialization/deserialization in WinRT (Store application)

I need to make a Windows Store application that exchanges xml serialized data over a TCP connection with a server. Since I need to use Direct3D rendering in the application I went for the c++/cx store application template however I ran into issues with xml serialization/deserialization.
My usual approach in C# would be to use the XmlSerializer and classes with DataContractAttribute annotations. However as soon as I try to import System.Xml.Serialization assembly I get the C1114 error - WinRT does not support #using of a managed assembly. However there are lots of examples that mention using this approach in a Windows Phone app from C#.
So the question is - is only c++/cx limited in support for .NET in Windows Store applications and C# can use all the standard components on phone as well or is switching to C# in this case also not a solution and I need to use the WinRT classes for xml serialization/deserialization?
Your confusion is understandable, what with the variety of frameworks Microsoft has put out there.
C++/Cx is a native binding to the Windows Runtime (WinRT). It does not use any managed code or the .NET framework in any way, which is why you're getting the C1114 error.
C# provides a managed binding to WinRT. It does leverage the .NET framework, so in a C# Windows Store application, you can make use of some of the base-class library. This subset is referred to as the .NET Profile. This article talks about this more: http://blogs.msdn.com/b/dotnet/archive/2012/04/17/net-for-metro-style-apps.aspx
In your specific case, you are using a C++/Cx application because you want access to Direct3D. This makes sense, although it means that you will not have access to System.Xml.Serialization. Instead, as you surmised, you will need to use APIs that are available to C++/Cx to read XML, specifically Windows.Data.Xml.Dom: https://msdn.microsoft.com/en-us/library/windows/apps/windows.data.xml.dom.aspx

How targeting .NET 4.0 with Mvvmcross?

I want to use Mvvmcross to make application for several platforms.
I use Profile 104 for PCL library like Mvvmcross, but this profile target .NET 4.5.
I want to target .NET 4.0 to use my application on Windows XP.
To do that, I add the xml files
MonoAndroid, Version = v1.6 +. Xml
and
VSMonoTouch, Version = v1.0 +. Xml
in the profile 143 which allows me to target. NET framework 4.0.3.
However, I have a compilation error because it can not find the ICommand interface.
This interface is not in the same library between version 4.0 and 4.5, is it why it doesn't work ?
Or should I recompile all Mvvmcross libraries with profile 143?
thanks,
This is a Portable Class Library limitation.
See the table on: http://msdn.microsoft.com/en-us/library/gg597391.aspx
Model-View-View Model (MVVM)
Only 4.5
This means that if anyone wants to use MvvmCross on earlier .Net platforms then someone has to build and maintain a non-PCL version.
Since the maintainer of Mvx (me!) has decided to only maintain PCL versions of MvvmCross, then any non-PCL support will have to be created by the community.
For WPF this shouldn't be too large or difficult a job - but it might be...
Alternatively, somebody might be able to do something funky to get the ICommand working... I've retagged this question with portable-class-library to try to lure in some of the MS experts.

A few questions about Metro style applications

I have a few questions about Metro style applications.
Do they require .NET Framework or any framework?
Which programming languages can be used to create Metro style apps?
Can they be cross platform?
It does not require using .NET - you can build native apps with C++ or C++/CX or use HTML and Javascript
C#, Visual Basic, C++, C++/CX, XAML, Javascript, HTML, CSS
It depends what you understand by cross platform - these apps can run on any Windows 8 platform, but not on Windows Phone, Mac or Linux
Metro applications are either developed using Microsoft .Net (c#) OR C++ OR HTML 5 / Javascript
Api Reference of Metro Aplication
For more detailed information, check this page : http://msdn.microsoft.com/library/windows/apps/
HTML5 - Javascript
These are the languages used by any browser, making them compatible on any system
Microsoft .Net
Can only be run on a Windows computer, but you may want to check Mono for compiling multi-platform applications made in C#
C++
Well C++ is c++... it can pretty much do anything anywhere

app.config supportedruntime element with .NET framework 3.5 SP1

I have a trivial C# windows application with an app.config file. I want to use the SupportedRuntime element to stipulate which version of the .NET framework to use. In my case, I want to use the .NET Framework 3.5 SP1.
Here is the XML I am using to achieve this;
[startup]
[supportedRuntime version="3.5.30729.1"/]
[/startup]
I have Microsoft .NET Framework 3.5 SP1 installed on my PC, but when I run the app, a message box advises me that I need to upgrade to this version of the .NET framework.
I hope this makes sense. Any ideas what the problem is?
(Edit: obviously the above code uses angle brackets rather than square brackets, but I couldnt see how to do that)
The answer is simple.
The .NET framework runtime version does not change with .NET 3.5 or 3.5 SP1, as these releases add additional libraries (Linq for example) but do not change the core runtime.
Hence entering the runtime version "3.5.30729.1" will never work.