microsoftgraph / microsoft-graph-comms-samples

Microsoft Graph Communications Samples
MIT License
211 stars 236 forks source link

Method not found KiotaClientFactory.Create after upgrading Communications packages #774

Open vidilab opened 1 month ago

vidilab commented 1 month ago

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" />

magnusdanielson commented 1 month ago

Same problem here.

stefan2410 commented 1 month ago

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

vipwlb commented 1 month ago

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

could you please try this one?

vipwlb commented 1 month ago

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

stefan2410 commented 1 month ago

@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.

magnusdanielson commented 1 month ago

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);
        }
bfany365 commented 4 weeks ago

May be this can help ?

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

stefan2410 commented 4 weeks ago

@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.

vidilab commented 4 weeks ago

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

I also have the same exception details as stefan2410

vipwlb commented 3 weeks ago

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