Two versions of System.Net.Http - c#

I have difficulties to understand dual existence of System.Net.Http. It exists as a part of .Net Framework 4.7 (in version 4.0.0.0), but is also available as a separate package in much newer version (version 4.3.2 as of now).
Why is it available twofold?
Why latest available version (probably 4.3) has not been included in .Net Framework 4.7 when it was released?

First, package version and assembly version can be different versions.
Package System.Net.Http, version 4.3.2: Assembly version is 4.1.1.1
I can't find a released package for System.Net.Http with assembly version 4.0.0.0, so I think that it's not distributed as a package, but there is at least one prerelease package which has that assembly, System.Net.Http, version 4.0.0-beta-22416. It seems that all prerelease packages from version 4.0.0-beta-22416 to version 4.0.1-rc2-24027 have .NET Framework versions of the assembly, with version 4.0.0.0.
.NET Framework 4.7 supports the APIs that exist in System.Net.Http, Version=4.0.0.0 and if you want extra functionality, you can pull extra APIs by installing a newer package, like you would do with any other package.

Related

Build Error after Upgrading microsoft.net.sdk.functions

My project uses .net framework 4.8. After upgrading microsoft.net.sdk.functions from version 1.0.24 to 3.0.1, the build on my local machine works fine, but there are some errors on the build on VSO pipeline:
microsoft.net.sdk.functions\3.0.1\build\microsoft.net.sdk.functions.build.targets(41,5):
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '3.0.0' was
not found
microsoft.net.sdk.functions\3.0.1\build\microsoft.net.sdk.functions.build.targets(41,5):
metadata generation failed.
There is no version 3.0.0 for Microsoft.NetCore.App nuget package. Why would the error ask for that version? Also how can I fix the error?
Looking at the package on NuGet, version 3.0.1 is intended for use with .NET Core 3.0 and higher applications, not .NET Framework applications. Version 1.0.38 appears to be the latest version with .NET Framework support (4.6 and higher).

Can I target both .net standard2.0 and net471 in csproj file

I have a project that the target framework is .net standard 2.0, we use the System.Runtime.InteropServices.RuntimeInformation.OSDescription in our source code, but this library isn't support .net framwwork 4.6.1.Yesterday, one of our customer report a bug, about this question. his local framework is .net framework 4.6.1.
Can I set the target Framework to make a notice to user during they add the reference from Nuget Package?
And to make user to know if your local framework is 4.6.1, you should not use this version package and will cause bug.
When I set the target frameworks to:
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net471</TargetFrameworks>
<PropertyGroup/>
Then run dotnet build I get the error message:
error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found.
To resolve this, install the SDK or Targeting Pack for this framework version
or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed.
Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies.
Therefore your assembly may not be correctly targeted for the framework you intend.
Then I go to the office website to download .net framework 4.7.1 SDK, but I install fail.
The error message is
A .NET Framework 4.7.1 or higher update has been installed on this computer
So I am confused!
Here is my dotnet --info
It seems I make a joke, I download the .net framework 4.7.1 from .net framework 4.7.1, but I can't install it. However, when I use Visual Studio Installer to install .net framework 4.7.1. It's fine.
And now run dotnet build, It success. More confused am I, Why can't install it from .exe file.

Could not install NuGet package MPI.NET 1.3.0 in MS Visual Studio 2017

I am trying to install NuGet package MPI.NET 1.3.0 to MS Visual Studio 2017 C# project. I am getting the following error:
Could not install package 'MPI.NET 1.3.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I have tried to create C# projects in different versions of .NET Framework, but it would not install. On the official GitHub site for this package (MPI.NET GitHub repository) it is written that the package is updated for .NET 4.0. I have tried creating 4.0 and lower projects, but no success.
Help anyone?
Looking at the packages available on nuget.org, version 1.3.0 targets .NET 4.6.2, whereas version 1.2.0 targets .NET 4.0. So if you try to install version 1.2.0 of the package into your project, you should be okay. It sounds like the GitHub documentation needs to be updated to reflect this new reality.
(Personally I would bump the major version number for a change like this, given that it's not necessarily backwardly compatible for existing users, but semantic versioning is less cut and dried than it sometimes sounds.)

Can I use "Roslyn" in Visual Studio 2017 with .NET 4.7?

I've upgraded my project with scripting capabilities and also Microsoft.CodeAnalysis nuget and it downloaded hundred of dependent System.* packages. Before it was only Microsoft.CodeAnalysis.Common, CSharp, CSharp.Workspaces, etc. What is happening? Does it work in Visual Studio 2017 with .NET Framework 4.7? Or is it included in 4.7 (I didn't find it anywhere)? Should I wait?
Older versions of Microsoft.CodeAnalysis.Common only had a variant for .Net 4.5, with few dependencies.
But since version 1.3.0, the package also has a .Net Standard 1.3 variant, which has many dependencies, as is usual for .Net Standard 1.x packages. When installing such package into a project targeting .Net Framework 4.7, NuGet installs all the .Net Standard dependencies. As far as I know, there is nothing wrong with that and the project should work fine.

Referenced Nuget package has errors finding system types

I have several strange errors after using NuGet to add a third party library to a project. The project targets .NET 4.5.2.
The errors I get complain of standard system types not being of the correct version
e.g.
CS0012: The type 'System.Collections.Generic.IEnumerable`1' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I have cleaned the project folder, deleted the bin folder, reinstalled the
NuGet package and readded the reference to no avail.
The library is Remotion.Linq
According to the Registry the following .NET versions are installed on the machine
v2.0.50727 2.0.50727.4927 SP2
v3.0 3.0.30729.4926 SP2
v3.5 3.5.30729.4926 SP1
v4
Client 4.6.01038
Full 4.6.01038
v4.0
Client 4.0.0.0
Does anyone know what is happening here?
This suggests the third party library targets 4.0 of the framework. You either need to find a later version of the library or in your project properties set the target framework to 4.0 as opposed to 4.5
This turned out to be a misleading error. The library was built against .NET 4.5.2 but I had .NET 4.5.1 installed.
Microsoft explain this in a KB article (KB2971005) but you really need to know what the issue is to easily find the article. I somehow stumbled across it after a lot of searching.
The resolution is to install the updated version of the Microsoft .NET Framework 4.5.2 Developer Pack.

Categories

Resources