tihomir-kit / InfluxData.Net

InfluxData TICK stack .net library.
MIT License
156 stars 52 forks source link

System.Net.Http wrong version. #72

Closed awb99 closed 1 year ago

awb99 commented 6 years ago

InfluxData.Net uses System.Net.Http 4.1.1.1

If I just require the latest version (v8) via nugget, and then use the .net 4.6.1 I am getting errors that the version of System.Net.Http is not the one in the manifest.

I solved the issue by cloning the library and then referencing all the dlls of the library including System.Net.Http and Newtonsoft.Json as they came out from the compiler for the library. That is a hack.

It should work straight out of the box via nuget or paket.

I assume there must be a way how to make a declaration in app.config to use a newer version of System.Net.Http; but I was unable to do so.

I should note that when I was adding the references for System.Net.Http I often got multiple System.Net.Http references added; and I then had to delete the newer one.

I assume the issue is either in InflusData.NEt library or in the usage of Newtonsoft.Json.

awb99 commented 6 years ago

I want to note additionally, that If I use a framework higher than 4.6.1 then even my hack does not work anymore.

tihomir-kit commented 6 years ago

Hi, could you perhaps provide a small demo sln of your setup so I could reproduce this? It'll be very hard for me to do it otherwise as in all the places I'm using this (in production) it works fine for me. Thnx.

awb99 commented 6 years ago

https://github.com/awb99/influxTest

HACK folder has a solution where I just copied the dlls from the influxdata.net project - this works.

DEMO folder is using dependencies managed by packet. so I did do "packet install" - this has the issues.

errors

You see that the dependency System.Net.Http appears 2 times; but I added it only once.

This is my paket dependency file:

source https://www.nuget.org/api/v2
nuget InfluxData.Net
nuget System.Net.Http 4.1.1

I tried requesting 4.1.1.1 but it is not possible. Only 4.1.1 can be requested via nuget.

tihomir-kit commented 6 years ago

Thnx, I'll try to take a look at this over the weekend. In the meantime, a bindingRedirect might help you:

https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/bindingredirect-element https://stackoverflow.com/questions/16920370/why-is-a-bindingredirect-added-to-the-app-config-file-after-adding-the-microso https://johnnycode.com/2013/07/19/fixing-assembly-binding-redirect-errors/

awb99 commented 6 years ago

@pootzko I tested today with mono on arch linux. Funnily when I compile under mono as .net 4.6.2 solution.. then all dependencies work fine with nuget / paket.net Perhaps some installation issue of having differnet .net frameworks on windows that caused my issues.. I will experiment some more next week...

gsokoll commented 6 years ago

I'm having the same issue. Current targeting .Net framework 4.7.2. Any suggestions ?

Zero3 commented 5 years ago

Microsoft recently made a real mess of System.Net.Http. One interesting detail is this comment from a guy from Microsoft:

It is not clear from our instructions, and we are working on how to fix it but System.Net.Http package should NOT be referenced from an application that targets .NET Framework. System.Net.Http ships with the framework so it is installed in the GAC, similar to mscorlib.dll. For this reason, applications and libraries targeting .NET Framework should reference the inbox version instead (meaning a regular in your csproj or adding it through the solution explorer.)

(https://github.com/dotnet/standard/issues/936#issuecomment-432710321)

I realized I had this dependency in my project because InfluxData.Net depends on it. Maybe this dependency should be removed?