microsoftgraph / msgraph-sdk-dotnet

Microsoft Graph Client Library for .NET!
https://graph.microsoft.com
Other
703 stars 249 forks source link

Microsoft.Graph 4.x References System.Net.Http.WinHttpHandler v6.0.1 which isn't available in .Net Framework 4.6.2 #1506

Open dave-carlson opened 2 years ago

dave-carlson commented 2 years ago

Originally from Microsoft Support TrackingID #2208010010002604

Why is the assembly System.Net.Http.WinHttpHandler v6.0.1 required to be loaded with .Net framework 4.6.2 if this is not usable until .NET 5?

While compiling the app using SQL Server Integration Service 2019, which uses Visual Studio Tools for Applications, and Microsoft.Graph dotnet v4.x or higher we get the following error:

Could not load file or assembly 'System.Net.Http.WinHttpHandler, Version=6.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Due to the SSIS dependency, the target .NET framework is 4.7 (even in SSIS 2019) and the maximum targetable is 4.8. SSIS only allows referencing assemblies loaded through reflection from a local file path or registered in the local GAC.

This is not a problem with Microsoft.Graph dotnet v3.x This is not a problem with Visual Studio 2019 or 2022 (This is probably because the nuget package is automatically installed with the package manager)

Based on the WinHttpHandler doc, this class is only available in System.Net.Http starting with .NET 5 https://docs.microsoft.com/en-us/dotnet/core/compatibility/networking/5.0/winhttphandler-removed-from-runtime

msgraph-sdk-dotnet-core/Microsoft.Graph.Core.csproj at dev · microsoftgraph/msgraph-sdk-dotnet-core · GitHub

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
    <PackageReference Include="System.Net.Http.WinHttpHandler" Version="6.0.1" />
</ItemGroup>
andrueastman commented 2 years ago

Thanks for raising this @dave-carlson,

I believe the reference is targeting the nuget package at https://www.nuget.org/packages/System.Net.Http.WinHttpHandler/ which supports NET Framework 4.6.1 and above. So, you should be able to use it if the dependency manager resolves this. Any chance the issues is resolved if you register the given package?

dave-carlson commented 2 years ago

Unfortunately, SSIS doesn't allow the use of the dependency manager to resolve references. In order to use a library not included in the base framework, you are required to manually download the library to the system the SSIS package will run on and either register it in the GAC or load it through reflection.