My DLL is created using the .NET Standard 1.6 and ASP.net is using .NET Framework 4+
This is the Error that I am getting
Severity Code Description Project File Line Suppression State
Error Project targets '.NETStandard,Version=v1.6'. It cannot be
referenced by a project that targets
'.NETFramework,Version=v4.5.2'. WebApplication
Is there a work around for this ? Using the old ASP.NET framework instead of the new ASP.NET Core
I am not a fan of the Razor syntax, however I would like to use the old aspx syntax to create web forms.
Using : VS - 2017
Only .Net Framework 4.6.1 with tooling 2.0 supports .Net Standard 1.6. You will not be able to use DLL targeting .Net Standard 1.6 in application that's targeting .Net Full framework 4+ except 4.6.1 with tooling 2.0. Please refer this link for more details on platform support and compatibility.
It's like referencing a 4.5 assembly from a 4.0 project:
To see what .net standard version is implemented by what version of the .net framework, see: https://blogs.msdn.microsoft.com/dotnet/2016/09/26/introducing-net-standard/
Related
In one of my .NET Framework projects, I introduced a new .NET Standard 2.0 project. This project has dependencies on some existing .NET Framework projects. I was wondering if this is right to do.?
The reason I added a .NETStandard project is that we have plans to move the whole repository to .NET Core / Standard. Hence I thought, the new project we add can target .NET Standard. With .NET Standard project I get the new SDK style project file, package references, etc by default.
The consuming application is still .NET Framework.
Do I have to retarget the new project to .NET Framework 4.7.2 so that the project will have the above SDK style project file and package references but targets .NET Framework 4.7.2 now. It will then be as easy as changing the target framework when we move to .NET Core?
Depends on your purpose of introducing the Standard 2.0 project. Normally, you make a Standard when you need it to be accessible both from .NET Framework and Core. In your case, your Standard project won't be operable from Core under macOS or Linux.
Yes, this can be done.
https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0
.NET Framework compatibility mode
Starting with .NET Standard 2.0, the .NET Framework compatibility mode was introduced. This compatibility mode allows .NET Standard projects to reference .NET Framework libraries as if they were compiled for .NET Standard. Referencing .NET Framework libraries doesn't work for all projects, such as libraries that use Windows Presentation Foundation (WPF) APIs.
This is necessary as an intermediate step for some projects, but in order to get to your final goal you will of course have to go all in on .net core which will require updating those projects not to use framework or they will crash at runtime.
I have a DLL(Say FileWrapper.dll) that is build using .Net Framework 4.5 (Build for linux)
Is it possible to build a console application (in .Net Core 2.2 - For Linux) that has references FileWrapper.dll and use various functions within in FileWrapper.dll.
Any pointers or past experience is helpful.
Building .net core 2.2 console app for Linux using dll build in .Net Framework 4.5
No Code specific
Hoping to build .net core console app that uses a dll build in .net framework 4.5
Yes, this is possible and was introduced with the .NET standard 2.0 which is supported by .Net Core 2 and .Net Framework 4.6.1. The concept is described is called a "compatibility shim" in .Net Standard 2.0. Here are a couple of links to get you started
Building a Compatibility Shim with .Net Standard 2.0
stack overflow - Compatibility shim used by .Net Standard 2.0
Referring to Why use the full .NET Framework with ASP.NET Core?, it appears .NET 4.7.2 is the way to go forward?
Our existing application targets .NET 4.6.1 using ASP.NET Boilerplate.
Is it mandatory to migrate to .NET 4.7.* in order to leverage ASP.NET Core 2.1 features?
To use .NET Core 2.1 features, you need to target .NET Core 2.1
There is .NET Standard, which is an intersection of features that are available in a range of implementations, including .NET Core and .NET Framework. If you target .NET Standard (some specific version), then you can use the features available in that version of .NET Standard, and it should run on either .NET Framework 4.7.2 or .NET Core 2.1.
As a general guide: libraries (such as Aspnet Boilerplate) should now - where possible - target .NET Standard, but will often have a multi-target build to allow them to internally exploit target-specific features of specific frameworks (perhaps using the enhanced "span" or SIMD capabilities in .NET Core).
Application code should (and must, if it is an executable) target a specific framework such as .NET Framework or .NET Core.
No, it is not necessary to migrate to .NET 4.7.* in order to leverage ASP.NET Core 2.1 features.
ASP.NET Core 2.x is made up of .NET Standard libraries. Apps written with .NET Standard 2.0 run anywhere that .NET Standard 2.0 is supported.
ASP.NET Core 2.x is supported on .NET Framework versions compatible with .NET Standard 2.0:
.NET Framework 4.7.1 and later is strongly recommended.
.NET Framework 4.6.1 and later.
You only need to migrate to .NET 4.7.2 if you need features in Announcing .NET Framework 4.7.2:
ASP.NET – Dependency Injection in WebForms
ASP.NET – SameSite Cookie
ClickOnce – Per-monitor support for WPF and HDPI-aware ClickOnce deployed apps
ClickOnce – Enable SHA256 timestamping of Deployment Manifests
SQL – Azure AD Universal and Multi-factor Authentication Support
BCL – Cryptographic Improvements
BCL – ZLib decompression support to DeflateStream
BCL – Additional Collection APIs
WorkflowDesigner High Contrast Improvements
WPF – Finding ResourceDictionaries by Source
WPF – Finding ResourceDictionary owners
WPF – Finding StaticResource references
References:
ASP.NET Core targeting .NET Framework
.NET Standard implementation support
For real, if you're building an application using .NET Core/Standard, but in your application, you may have some reference that using .NET Framework, it must be a big problem.
A story: I'm building a web application using ASP.NET Core, in this application, I want to have an extension that converting HTML to pdf.
I've tried to searched on Google and found a plugin that is called: itextsharp. And the problem comes from here.
itextsharp is using .NET Framework while my main project is using .NET Core. Since I want to create a class library to build this extension, I have 3 options:
Using .NET Core class library.
Using .NET Standard class library.
Using .NET Framwork class library.
All of them can be refered to the main project. BUT:
I cannot use itextsharp references (itextsharp.dll, itextsharp.xtra.dll, itextsharp.pdfa.dll, itextsharp.xmlworker.dll...) in .NET Core/Standard class libray. All of them can run only on target .NET Framework.
(I haven't mentioned about how to convert the code to target .NET Standard or Core because of license yet)
And my solution is: Build a .NET Framework app and publish it to exe file before appending to the main project as a reference.
P/S: For now, itextsharp has a Core version but I think it's not good enough (problems about: displaying images, fonts with unicode text, style tag...).
Totally, if you want to build some app that is using target .NET X, you must make sure all of the references can use target .NET X, too.
Another example: if you want to build a class library that using Razor class library. You must make sure that all of the references are using target .NET Core/Standard. Because Razor class library cannot refer to .NET Framework class library.
I've got a strange issue referencing a net standard application (FW Full 4.5.2)
I got this error targets 'netstandard2.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.5.2'., wasn't .NET standard supposed to allow references from Core and Framework projects as well?
As stated here .NET implementation support. You need atleast .NET Framework 4.61 for referencing .NET Standard 2.0 assemblies.
I can easily create a vNext class library that compiles the source to .NET 4.5 and ASP.NET Core. I can also create a target for PCL (net40+sl50+wp80+win+wpa81+MonoAndroid10+MonoTouch10). The problem is that I would like my library to also target 3.5 but adding net35 to the "frameworks" list adds an entry in the references but expanding that shows that it actually imports .NET 4.5 assemblies so the compiled result is not targeting .NET 3.5 but instead 4.5...
Is is possible for the vNext class library to target .NET 3.5?
The references displayed on VS2015 show indeed a link to .NET 4
But the generated NuGet shows 3.5 :
However I was not able to test of this really works when running on Windows with only 3.5 installed.