英文:
Isolated Azure Function throwing error on startup
问题
我正在努力将所有我们的C# Azure函数转换为与进程隔离,但遇到了一个我找不到任何信息的错误。我在启动时收到的错误是:
找不到方法: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.RegisterDefaultConverters(Microsoft.Extensions.DependencyInjection.IServiceCollection)'。
我的Program.cs可能再简单不过了:
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
await host.RunAsync();
我的.csproj文件包含了比我需要的扩展更多,但我一直在尝试不同的扩展来看是否会有任何变化:
<PackageReference Include="Microsoft.Azure.AppConfiguration.Functions.Worker" Version="6.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights" Version="1.0.0-preview4" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="5.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.12" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Warmup" Version="4.0.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
英文:
I'm working on converting all of our c# Azure functions to be isolated from in-process but am running into an error that I can't find any information on. The error I am getting on startup is:
> Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.RegisterDefaultConverters(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
My Program.cs couldn't be simpler I don't think:
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
await host.RunAsync();
My .csproj has more extensions than I need but been throwing extensions at it to see if anything changes:
<PackageReference Include="Microsoft.Azure.AppConfiguration.Functions.Worker" Version="6.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights" Version="1.0.0-preview4" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="5.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.12" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Warmup" Version="4.0.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
答案1
得分: 0
我减少了对包的引用,一切都开始正常工作了。仍然不理解这个错误的含义。
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.12" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" />
英文:
I scaled back on my package references and everything started working. Still don't understand what the error means
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.12" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" />
答案2
得分: 0
通常这种异常表示包版本不匹配(特别是当未正确处理破坏性更改时),在这种情况下 `Microsoft.Azure.Functions.Worker` 是罪魁祸首 - 更新它(似乎其中一个依赖项已移除了 `RegisterDefaultConverters` 扩展方法,另外似乎 `Microsoft.Azure.Functions.Worker.Sdk` 也可以/需要更新):
```xml
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.13.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.9.0" />
<details>
<summary>英文:</summary>
Such exceptions usually denote a package version mismatch (especially when breaking changes are not handled correctly), in this particular case `Microsoft.Azure.Functions.Worker` is the guilty one - update it (it seems that one of the dependencies has removed the `RegisterDefaultConverters` extension method,
also it seems that `Microsoft.Azure.Functions.Worker.Sdk` can be/needs to be updated also):
```xml
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.13.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.9.0" />
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论