microsoftgraph / microsoft-graph-comms-samples

Microsoft Graph Communications Samples
MIT License
208 stars 231 forks source link

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

Open vidilab opened 1 week ago

vidilab commented 1 week 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 4 days ago

Same problem here.

stefan2410 commented 23 hours 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 16 hours ago

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

could you please try this one?

vipwlb commented 15 hours ago

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

stefan2410 commented 7 hours 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 hour 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);
        }
stefan2410 commented 12 minutes ago

@magnusdanielson what Kiota version, do you have in your project ?