3

I started a web project with .net core 2.1 and it works just fine.

But now a vendor says his server side component only works with .net 4.6.1

Can I now change the target framework on the project to 4.6.1 without rewriting the app?

The component helps export data to PDF and Excel, and uses many of the Standard Libraries. So I am at a loss on how to integrate this.

One idea is to create a separate API server that is on 4.6.1, for just the data export but the issue with that is security - the end user is logged into Server A, not Server B, so there are now security issues to deal with.

Maybe calling server B directly from Server A would be possible so I know the person is logged in, then returning the result back to the end user from Server A.

NOTE:Edit to 4.6.1 from 4.7.2 in the above in case that makes any difference.

Ade Stringer
  • 2,611
  • 17
  • 28
Greg Gum
  • 33,478
  • 39
  • 162
  • 233
  • 1
    Be more specific. What component, how does it interact? Can you write a proxy or wrapper? – Igor Sep 08 '18 at 17:49
  • 2
    No, .NET and .NET Core are totally separate products with separate runtimes, libraries etc. You can't just switch your code between them without some changes. – ADyson Sep 08 '18 at 17:49
  • @ADyson yes they are totally separate products, but they do both share netstandard libraries which is what 90% of what of the libraries asp.net are targeting. – Scott Chamberlain Sep 08 '18 at 17:54
  • @ScottChamberlain true the number of .NET Standard libraries is increasing, but many 3rd party libraries such as the one mentioned in the question are still made specifically for one or the other. – ADyson Sep 08 '18 at 17:56
  • The vendor should be clear on their side too. Supporting .NET Framework 4.7.2 is ambiguous, as ASP.NET Core apps can definitely run on .NET Framework, but a component designed for ASP.NET 4.x won't automatically be compatible to ASP.NET Core. – Lex Li Sep 08 '18 at 18:33

2 Answers2

2

Yes you can. Simply follow this here

Pulling code from the Stackoverflow link, you simply modify the .csproj file to suit your needs to the .NET Standard lib you're targeting.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
  </PropertyGroup>
</Project>

By judging from the documentation provided by Microsoft and by a 3rd party service, you're advised to target .NET Standard for your .NET Core project in order to maximize compatibility with your vendor first. From there, you may most likely one to deploy a second server that completely targets .NET Core to roll out functions with modern APIs.

Take note that .NET Core 2.1 targets 4.6.1 onwards meaning that you will be writing a project that is unable to support anything older than that.

Nicholas
  • 1,883
  • 21
  • 39
  • What does that really mean '.net Core 2.1 targets 4.6.1'? To me, that would mean that 2.1 would run just fine in a 4.6.1 project. – Greg Gum Sep 08 '18 at 18:49
  • @Greg0 yup that's right. Just a heads up for you there mate, the important part is to note that converting the .NET Core project to a .NET Standard project would significantly increase reusability – Nicholas Sep 08 '18 at 18:54
  • Ok, well I am going to give that a shot then and see how it goes. – Greg Gum Sep 08 '18 at 19:01
  • Cheers mate, @Greg0 let me know if you need anything else – Nicholas Sep 08 '18 at 19:03
2

I want to note that the easiest way to run .netcore on the full .netframework is to start with such a project.

You can select .netcore/.net framework when you create the project. This will select all the correct libs for you to get started. Switching midstream can be done, but it takes fiddling with the libs to get the correct versions.

enter image description here

Greg Gum
  • 33,478
  • 39
  • 162
  • 233