我在Visual Studio中有一个C#(Azure函数应用程序)项目。.Net 6.0
我更新了RestSharp到110.2.0版本,现在我得到这个错误:
[2023-04-29T21:34:10.399Z] Executed 'RequestItemsPage' (Failed, Id=8eefbb7c-3bc0-44db-81e4-14c56096fc81, Duration=63ms)
[2023-04-29T21:34:10.401Z] System.Private.CoreLib: Exception while executing function: RequestItemsPage. System.Private.CoreLib: Exception has been thrown by the target of an invocation. RestSharp: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
[2023-04-29T21:34:10.408Z] eb4802876b9e44839f63422be68619dc: Function 'RequestItemsPage (Activity)' failed with an error. Reason: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
[2023-04-29T21:34:10.411Z] ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
[2023-04-29T21:34:10.412Z] File name: 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
[2023-04-29T21:34:10.413Z] at RestSharp.Serializers.Json.SystemTextJsonSerializer..ctor()
[2023-04-29T21:34:10.423Z] at System.RuntimeType.CreateInstanceOfT()
[2023-04-29T21:34:10.423Z] --- End of inner exception stack trace ---
[2023-04-29T21:34:10.427Z] at System.RuntimeType.CreateInstanceOfT()
[2023-04-29T21:34:10.429Z] at System.Activator.CreateInstance[T]()
[2023-04-29T21:34:10.430Z] at RestSharp.Serializers.SerializerConfig.<>c__5`1.<UseSerializer>b__5_0()
[2023-04-29T21:34:10.434Z] at RestSharp.Serializers.SerializerConfig.UseSerializer(Func`1 serializerFactory)
[2023-04-29T21:34:10.438Z] at RestSharp.RestClient.ConfigureSerializers(ConfigureSerialization configureSerialization)
[2023-04-29T21:34:10.439Z] at RestSharp.RestClient..ctor(RestClientOptions options, ConfigureHeaders configureDefaultHeaders, ConfigureSerialization configureSerialization, Boolean useClientFactory)
[2023-04-29T21:34:10.444Z] at ContentHub_ItemUpdates.Producers.PullAllContentHubtemsByPage.RequestItemsPage(Int32 skip, ILogger log) in C:\Users\bwarrick\Workspace\.NET\Integrations_MDM\ContentHub_ItemUpdates\ContentHub_ItemUpdates\Producers\PullAllContentHubtemsByPage.cs:line 58
[2023-04-29T21:34:10.479Z] at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync(Object instance, Object[] arguments)
[2023-04-29T21:34:10.480Z] at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeWithTimeoutAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance instance) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 581
[2023-04-29T21:34:10.481Z] at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstanceEx instance, ParameterHelper parameterHelper, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 527
[2023-04-29T21:34:10.499Z] at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 306. IsReplay: False. State: Failed. HubName: TestHubName. AppName: . SlotName: . ExtensionVersion: 2.9.4. SequenceNumber: 7. TaskEventId: 0
这很奇怪,因为这个版本的RestSharp依赖于System.Text.Json >= 7.0.2。我检查了依赖项,它就在那里--我还看到更新时它正在升级System.Text.JSON。
我尝试安装System.Text.JSON的NuGet包。没成功然后我尝试卸载并重新安装RestSharp。清理重建正在重新启动Visual Studio。
我也试过降级Restsharp。我开始觉得我破坏了我的计划,需要放弃它...
对此有什么想法吗?
1条答案
按热度按时间flseospp1#
我已经创建了一个示例Http Azure函数来检查两个包的版本是否相互兼容,如doc中所述。我看不出包和它的版本有什么问题。
如您所述,RestSharp具有System.Text.Json作为依赖项,如下所示:*
我建议您从项目目录中删除
RestSharp
和System.Text.Json
DLL,并通过安装这些软件包的最新版本来重新添加它们,以确保没有冲突。请尝试使用
RestSharp 110.2.1-alpha.0.1
的最新预发布版本。此版本也与System.Text.Json
兼容,如doc所示。创建了一个示例项目,并安装了RestSharp 110.2.0和System.Text.Json 7.0.0包,并观察到这两个包版本彼此兼容。
结果: