Vet*_*and 2 c# json.net azure-functions
我正在开发Azure Functions"app",我正在本地进行大部分测试,然后将DLL发布到Azure.我从三月份开始,直到几周前一直运作良好.
我主要是在稳定的渠道上使用macOS High Sierra(目前是最新的; 10.13.4)和Visual Studio进行开发和测试.
我最近在提示我时更新了Visual Studio,它似乎已经更新为支持.NETStandard 2.0而非.NET Framework 4.7.*,但我的项目仍在.NET Framework 4.7上.然而,当我试图通过对admin-endpoint的POST请求运行我的计时器触发器时,我遇到一个错误,告诉我应用程序无法加载Newtonsoft.Json.
我一直在努力解决这个问题,最后用.NETStandard 2.0创建了一个新项目,只是复制了文件,但同样的错误仍然存在.
Newtonsoft.Json是从Visual Studio for Mac中的内置NuGet包管理器安装的.
我也在Windows上测试了同一个项目(Windows Server 2012 R2标准版),但我得到了完全相同的错误.
我得到的错误:
[06/05/2018 08:17:18] System.Private.CoreLib: Exception while executing function: Posts. MyAzureFunctionsApp: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
[06/05/2018 08:17:18]
[06/05/2018 08:17:18] Executed 'Posts' (Failed, Id=7c288cdf-7807-4450-92cd-c64370e241a5)
[06/05/2018 08:17:18] System.Private.CoreLib: Exception while executing function: Posts. MyAzureFunctionsApp: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
Run Code Online (Sandbox Code Playgroud)
Newtonsoft.Json版本11.0.0不存在,它目前版本为11.0.2,DLL版本为11.0.2.21924,所以我尝试了"绑定重定向".这似乎也没有任何区别.
app.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
<bindingRedirect oldVersion="11.0.0.0" newVersion="11.0.2.21924"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
的csproj文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
我已经清理了十几次项目,创建了一个全新的项目,删除了~/.nuget
,重新安装了Visual Studio并在Windows上测试了同一个项目.但我每次都会得到同样的错误.