Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinHttpHandler is only supported on .NET Framework and .NET Core runtimes on Windows in v2 function #3052

Closed
JohnReeson opened this issue Jun 25, 2018 · 7 comments

Comments

@JohnReeson
Copy link

Repro steps

Locally create a v2 function httptrigger (host version 2.0.11857), install System.Net.Http.WinHttpHandler package and new a WinHttpHandler object, WinHttpHandler handler = new WinHttpHandler();

Expected behavior

Works without error

Actual behavior

System.Private.CoreLib: Exception while executing function: TestWinHttpHandler. System.Net.Http.WinHttpHandler: WinHttpHandler is only supported on .NET Framework and .NET Core runtimes on Windows. It is not supported for Windows Store Applications (UWP) or Unix platforms.

Known workarounds

V1 works.

@JohnReeson JohnReeson changed the title How to use System.Net.Http.WinHttpHandler in v2 function how can we use System.Net.Http.WinHttpHandler in v2 function Jun 25, 2018
@JohnReeson JohnReeson changed the title how can we use System.Net.Http.WinHttpHandler in v2 function WinHttpHandler is only supported on .NET Framework and .NET Core runtimes on Windows in v2 function Jun 26, 2018
@mathewc
Copy link
Member

mathewc commented Jul 11, 2018

You are running on Windows, correct? (Not Linux). Can you also try validating against the latest bits? We've made a lot of enhancements since then.

@mathewc mathewc added this to the Active Questions milestone Jul 11, 2018
@JohnReeson
Copy link
Author

Yes, on Windows and also test in host 2.0.11888, same error.

@AdrianPell
Copy link

AdrianPell commented Nov 13, 2018

Any update on this issue? I've just run into it (using Google Ads API), and before I try to roll back to using Functions V1 - which is going to be painful reference-wise - I'd like to see if there's any workaround.

Apparently, switching Functions v2 to target .NET Core 2.1 doesn't help either :-(

@AdrianPell
Copy link

As a workaround, it's possible to put a local copy of the appropriate System.Net.Http.WinHttpHandler.dll file in the functions directory, and add the following to the csproj file:

  <ItemGroup>
    <None Update="System.Net.Http.WinHttpHandler.dll">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
  <Target Name="CopySPSM" BeforeTargets="Build">
    <Copy SourceFiles="System.Net.Http.WinHttpHandler.dll" DestinationFolder="$(OutputPath)\bin" />
  </Target>

@JohnReeson
Copy link
Author

@AdrianPell Thanks, the workaround works. Close it and link another one tracked.

@andrei-m-code
Copy link

andrei-m-code commented Nov 28, 2018

@AdrianPell @JohnReeson which one is "appropriate"? I am having exactly the same issue and I need this workaround to work. Where can I find the DLL that will work?

UPD: I just took the .NET Standard one and used the workaround above and it worked. It's weird.. Looks like function runtime for some reason uses incorrect nuget package assembly platform.

@AdrianPell
Copy link

@andrei-m-code Yes, the .NET Standard one would most likely be what you needed (assuming your project is targeting that of course). See @fabiocav comments here #3568 for more color on what's actually happening.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants