microsoft-graph-comms-samples icon indicating copy to clipboard operation
microsoft-graph-comms-samples copied to clipboard

Method not found KiotaClientFactory.Create after upgrading Communications packages

Open vidilab opened this issue 1 year ago • 11 comments

Using PolicyRecordingBot, when upgrading Microsoft.Graph.Communications.* from (12.0.7270) to latest (1.2.0.10563), some adjustment in code are needed, but when that is done, there is an exception during startup. It seems to occur at BuildCommunicationsClientBuilder.Build().

System.MissingMethodException: 'Method not found: 'System.Net.Http.HttpClient Microsoft.Kiota.Http.HttpClientLibrary.KiotaClientFactory.Create(System.Net.Http.HttpMessageHandler)'.'

All packages are updated to latest with NuGet.

Microsoft.Graph.Core : 3.1.22
Microsoft.Graph : 5.60.0
Microsoft.Graph.Communications.* : 1.2.0.10563

The reason to upgrade is the bug fixes in the new version. Is there a way to use the new package versions? The reference project (CRFrontEnd.csproj) in github uses an even older outdated version:

<PackageReference Include="Microsoft.Graph.Communications.Calls.Media" Version="1.2.0.3742" />

vidilab avatar Oct 10 '24 15:10 vidilab

Same problem here.

magnusdanielson avatar Oct 18 '24 07:10 magnusdanielson

Same problem here. .Net 4.8 Microsoft.Graph.Core : 3.1.14 Microsoft.Graph : 5.38.0 Microsoft.Graph.Communications.* : 1.2.0.10563

stefan2410 avatar Oct 21 '24 12:10 stefan2410

https://github.com/microsoftgraph/microsoft-graph-comms-samples/pull/777/files

could you please try this one?

vipwlb avatar Oct 21 '24 19:10 vipwlb

also, could you share the exception details? @vidilab @magnusdanielson

vipwlb avatar Oct 21 '24 19:10 vipwlb

@vipwlb in the Calls().OnIncoming += CallsOnIncoming.

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'System.Net.Http.HttpClient Microsoft.Kiota.Http.HttpClientLibrary.KiotaClientFactory.Create(System.Net.Http.HttpMessageHandler)'.
  Source=Microsoft.Graph.Communications.Calls
  StackTrace:
   at Microsoft.Graph.Communications.Calls.CommunicationsClientExtensions.<>c__DisplayClass0_0.<Calls>b__0()
   at Microsoft.Graph.Communications.Client.CommunicationsClient.GetOrAddResourceCollection[T](Boolean maintainState, Func`1 valueFactory)

In our environment .Net 4.8 Microsoft.Graph.Core : 3.1.14 Its transitive dependencies

[Microsoft.IdentityModel.Protocols.OpenIdConnect](https://www.nuget.org/packages/Microsoft.IdentityModel.Protocols.OpenIdConnect/) (>= 8.0.1)
[Microsoft.Kiota.Abstractions](https://www.nuget.org/packages/Microsoft.Kiota.Abstractions/) (>= 1.9.11)
[Microsoft.Kiota.Authentication.Azure](https://www.nuget.org/packages/Microsoft.Kiota.Authentication.Azure/) (>= 1.9.11)
[Microsoft.Kiota.Http.HttpClientLibrary](https://www.nuget.org/packages/Microsoft.Kiota.Http.HttpClientLibrary/) (>= 1.9.11)
[Microsoft.Kiota.Serialization.Form](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Form/) (>= 1.9.11)
[Microsoft.Kiota.Serialization.Json](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Json/) (>= 1.9.11)
[Microsoft.Kiota.Serialization.Multipart](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Multipart/) (>= 1.9.11)
[Microsoft.Kiota.Serialization.Text](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Text/) (>= 1.9.11)
[System.Net.Http.WinHttpHandler](https://www.nuget.org/packages/System.Net.Http.WinHttpHandler/) (>= 6.0.0 && < 9.0.0)

With the dependencies of Microsoft.Graph.Communications.Core 1.2.0.10563 to Graph.Core (>= 3.1.3 && < 4.0.0) and the dependencies of Microsoft.Graph.Communications.Core 1.2.0.10563 to Kiota.

[Microsoft.Kiota.Abstractions](https://www.nuget.org/packages/Microsoft.Kiota.Abstractions/) (>= 1.7.2)
[Microsoft.Kiota.Authentication.Azure](https://www.nuget.org/packages/Microsoft.Kiota.Authentication.Azure/) (>= 1.1.2)
[Microsoft.Kiota.Http.HttpClientLibrary](https://www.nuget.org/packages/Microsoft.Kiota.Http.HttpClientLibrary/) (>= 1.3.3)
[Microsoft.Kiota.Serialization.Form](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Form/) (>= 1.1.1)
[Microsoft.Kiota.Serialization.Json](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Json/) (>= 1.1.2)
[Microsoft.Kiota.Serialization.Multipart](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Multipart/) (>= 1.1.1)
[Microsoft.Kiota.Serialization.Text](https://www.nuget.org/packages/Microsoft.Kiota.Serialization.Text/) (>= 1.1.1)

we got other exception, (see below) . in the Calls().OnIncoming += CallsOnIncoming.

MissingMethodException: Method not found: 'System.String Std.UriTemplate.Expand(System.String, System.Collections.Generic.Dictionary 2<System.String,System.Object>).

So we updated to Microsoft.Graph.Core : 3.1.14 and we got the exception first mentioned in my comment.

stefan2410 avatar Oct 22 '24 03:10 stefan2410

also, could you share the exception details? @vidilab @magnusdanielson

I have the same exception as @stefan2410

in the Calls().OnIncoming += CallsOnIncoming.

System.MissingMethodException
  HResult=0x80131513
  Message=Method not found: 'System.Net.Http.HttpClient Microsoft.Kiota.Http.HttpClientLibrary.KiotaClientFactory.Create(System.Net.Http.HttpMessageHandler)'.
  Source=Microsoft.Graph.Communications.Calls

As far as I can see the problem is in the Calls() method. The strange thing is that if I copy the code from the Calls() method and create my own Callsz() method with just the call to the factory, I dont get the error.

public static void Callsz(this ICommunicationsClient client, bool maintainState = true)
        {
            HttpClient httpClient = KiotaClientFactory.Create((HttpMessageHandler)null);
        }

magnusdanielson avatar Oct 22 '24 10:10 magnusdanielson

May be this can help ?

https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2694

bfany365 avatar Oct 23 '24 13:10 bfany365

@bfany365 with Microsoft.Graph.Core, 3.1.3 we should add Std.UriTemplate 0.048 to the nuget packages in order to work. Now our problem is what to do with our other libraries using higher versions of Graph.Core (our other libraries use 3.1.4 which has dependencies to Kiota 1.9.1.1. ) For testing purposes, we isolated them.

stefan2410 avatar Oct 23 '24 18:10 stefan2410

also, could you share the exception details? @vidilab @magnusdanielson

I also have the same exception details as stefan2410

vidilab avatar Oct 25 '24 06:10 vidilab

A known issue was reported that found interaction of Graph Communications SDK nugets with Graph Core version 3.1.22. Graph.Core's internal Kiota lib dependency are conflicting with the Graph Commmunications Call SDK internal dependency. This is causing runtime issues so kindly refrain from Graph.Core version upgrades if using Graph Communications Calls nuget packages. the issue is not with Graph Core directly but with Graph Core's dependency on Kiota lib

vipwlb avatar Oct 26 '24 00:10 vipwlb

I request to update the version constraint for the following dependencies (perhaps updating just the first one is sufficient) in the Microsoft.Graph.Communications.Core (and the friends as appropriate) packages:

  1. Microsoft.Kiota.Http.HttpClientLibrary: from (>= 1.3.3) to (>= 1.3.3 && <= 1.4.1)
  2. Microsoft.Graph: from (>= 5.38.0) to (>= 5.38.0 && <= 5.54.0)
  3. Microsoft.Graph.Core: from (>= 3.1.3 && < 4.0.0) to (>= 3.1.3 && < 3.1.12)

Doing this would save time for many users.

rabindra-harlalka avatar Jul 11 '25 12:07 rabindra-harlalka