C
C#2y ago
nauvran

❔ iHttpClientFactory in net 461

Having some issues building my project in a Azure DevOps pipeline after I tried to use ihttpclientfactory to deal with socket exhaustion and so on Getting this lovely message and I can't figure out how to handle it Package Microsoft.Extensions.Http 3.1.32 is not compatible with net461 (.NETFramework, Version=v4.6.1). Package Microsoft.Extensions. Http 3.1.32 supports: - netcoreapp3.1 (.NETCoreApp, Version=v3.1) netstandard2.0 (.NETStandard, Version=v2.0) One or more packages are incompatible with .NETFramework, Version=v4.6.1.)
38 Replies
Cracker
Cracker2y ago
it actually says all
Cracker
Cracker2y ago
its not directly compatible but looks like it supports additionally
Cracker
Cracker2y ago
Do you have this error on local build ? and can you share your csproj ? where does Azure DevOps resolves nuget dependencies
nauvran
nauvranOP2y ago
Oh didn't get a notification It works fine when building on my local pc Issue with DevOps is that I have to upload the nuget packages to artifacts first since we're not allowed outside connections to the server Ah you're thinking I'm missing the standard 2 reference Which i am
Cracker
Cracker2y ago
we have similar approach where I work but we have access to nuget.org so you are copying Microsoft packages from nuget.org to your custom azure feed ?
nauvran
nauvranOP2y ago
Yeah I can't access it directly Have to upload whatever nugets I downloaded locally Yes
Cracker
Cracker2y ago
i see
nauvran
nauvranOP2y ago
Mhm The main apps webconfig is targeting 4.5 The class library where I use the httpclientfactory is targeting 4.6.1
Cracker
Cracker2y ago
do you have following folders in your copied package ?
Cracker
Cracker2y ago
netstanndard2.0 is compatible with framework 4.6.1
Cracker
Cracker2y ago
main app might causing the issue
nauvran
nauvranOP2y ago
Sorry for the phone camera Can't have discord on my work laptop
nauvran
nauvranOP2y ago
Fuck i hope not
Cracker
Cracker2y ago
which version of Microsoft.Extensions.Http did you download from nuget.org
nauvran
nauvranOP2y ago
I'm an idiot Sorry hang on Been a long day
Cracker
Cracker2y ago
should be the one of netstandard supporting
nauvran
nauvranOP2y ago
Project didn't have a netstandard 2 folder Only after I added the targeted framework and now the project obviously won't build because the main one is 4.5 Great
Cracker
Cracker2y ago
you can download Microsoft.Extensions.Http 3.1.32 from nuget.org, that one has netstandard support still main app is 4.5 which makes me uncomfortable looks like there is no version of Microsoft.Extensions.Http that supports framework 4.5
nauvran
nauvranOP2y ago
HM Managed to get it to accept having netstandard 2.0 in the target framework of the class library But it's complaining about system.data.sqlclient being gone Intellisense is of no use
Cracker
Cracker2y ago
while your class lib supports ns2.0 but referenced package doesn't, it wont compile for ns2.0 output even if your class lib supports ns2.0, netframework4.5 still not compatible with it
nauvran
nauvranOP2y ago
Yeah that makes sense Bah I am so tired of this project Can't even upgrade the framework
Cracker
Cracker2y ago
its pain to work with framework projects, even csproj is pain I feel you
nauvran
nauvranOP2y ago
It's not as much trouble when it isn't a decade old It's all this old outdated crap that I struggle with every day
Cracker
Cracker2y ago
I started industry with netcore3.1 but work life surely put me into framework projects
nauvran
nauvranOP2y ago
Both 461 and webforms No Oop or EF, just pure sql and triggers
Cracker
Cracker2y ago
plus work computer and access limitations 🙂 any chance we work in same place ? is it bank ?
nauvran
nauvranOP2y ago
Hah yeah I have to make myself admin and boot VS in admin or I can't even build Healthcare so nah
Cracker
Cracker2y ago
nvm
nauvran
nauvranOP2y ago
So got any good ideas on some alternative solutions to dealt with httpclient and socket exhaustion and all that Just say fuck it and do a singleton client? Not like the DNS for my own api is going to change I hope
Cracker
Cracker2y ago
HttpClient is fine most of the time there should me some configuration for DNS changes wrap the HttpClient with your custom service that handles conections properly
nauvran
nauvranOP2y ago
Not entirely sure what you mean
Cracker
Cracker2y ago
like create a helper class and create HttpClient instances as static only in that class and use post, get methods that will be more managble for future if want to upgrade client factory
nauvran
nauvranOP2y ago
Hmm Originally had it in a service that did that and handled the calls
Cracker
Cracker2y ago
I don't know else alternative, you can create new post for that specifically if someone else has ideas
nauvran
nauvranOP2y ago
I don't really see many other options considering I'm locked by frameworks Oh well thanks for the help!
Cracker
Cracker2y ago
np, good luck
Henkypenky
Henkypenky2y ago
sorry for the alte reply, IHttpClientFactory is not available in any .net framework version you need to target .net standard 2.0
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server