-1

I'm porting my project from .net framework 4.5.2 to .net standard. I have read this article for guiding. As i see in that article, .net framework 4.5.2 should implement .net standard 1.2 or 1.3 (as in the table there are .net framework 4.5.1 and 4.6 but not 4.5.2 so i'm not sure).

So, it should be suitable for targeting my project to .net standard 1.3. I think, I can re-target without any error if my project just use .net framework libraries. However, when i run the .NET Portability Analyzer tool. It shows that System.Xml.XPath.XPathNodeIterator is just supported in .net framework 4.5.2 and not in .net standard 1.3. I have to target .net standard 2.0 to make it work.

It really make me confuse. Do i mis-understand something here?

Chris F Carroll
  • 11,146
  • 3
  • 53
  • 61
khoa_chung_89
  • 975
  • 9
  • 25
  • I think i have a mis-understanding about .net standard here. Net standard contain base library only and that can be added through version to version so it won't contain all .net framework or any other framework (.net core, xamarin...) at corresponding version. However, i just still confuse in my case. If i know .net standard 1.3 is corresponding with .net framework 4.5.2 so what is this information useful for? – khoa_chung_89 Mar 12 '19 at 05:05
  • .NET Standard 1.3 API is a subset of .NET Framework 4.5.2 API, then where is the confusion? – Lex Li Mar 12 '19 at 05:11
  • Yes, see it, after reading more about .net standard. But, the version 1.3 has any meaning? It looks like i have to run the .NET Portability Analyzer tool (or build my project) to decide the suitable .net standard version with knowing it's 1.3 or not. – khoa_chung_89 Mar 12 '19 at 05:19
  • https://blog.lextudio.com/tips-for-net-nuget-package-authors-august-2017-48f07604e4a0?gi=1591634a7370 Use multi targeting and then the code works for both worlds. – Lex Li Mar 12 '19 at 05:21

2 Answers2

0

On the page you have in your link there is a different table describing the .NET Standard support: https://learn.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support

  • .NET Standard 1.2 is supported on .NET Framework 4.5.1
  • .NET Standard 1.3 is supported on .NET Framework 4.6

The type XPathNodeIterator is not part of .NET Standard until .NET Standard 2.0. You can use https://apisof.net/catalog/System.Xml.XPath.XPathNodeIterator to see that.

That type is available as a NuGet package that you can take a dependency on if your library targets .NET Standard 1.6. That package name is System.Xml.XPath.

That being said, if you want to support .NET Standard as well as .NET Framework you can multi target. This will build 2 dlls, one targeting .NET Standard and one targeting .NET Framework. As long as the APIs are available in both versions, this should work.

Alex Ghiondea - MSFT
  • 3,182
  • 1
  • 8
  • 11
0

To migrate nearly-painlessly from net framework to netcore or netstandard target netstandard2.x, or one of the netcore___2.x target.

Trying to migrate a large existing netframework project to netstandard 1.x or netcore 1.x is a painful experience. And since netcore2 exists it is now both painful and futile. Netcore 1.x was missing a lot of NetFramework APIs that you just expected to work in a net framework project. So then your migrated project doesn't build and you have lots of work to fix it.

But if you move your existing code into a new Netstandard/netcore 2 project, then most of the Framework 4.x API is there, and lots more things 'just work' with minimal change. Obviously you have to re-add NuGet and other dependencies.

For the things that don't 'just work', I did a blog about multi-targeting netframework/netcore which includes a section on some of the gotchas for moving between the two targets.

Chris F Carroll
  • 11,146
  • 3
  • 53
  • 61