我使用Azure函数工具创建了一个全新的项目,其中包含Azure函数V1:
然后我点击F5并获得黄色闪电然后出现错误消息:
" An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = WebScriptHostManager (DelegateActivator), Services = [Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostManager], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = ExternallyOwned ---> The type initializer for 'Microsoft.Azure.WebJobs.Script.Utility' threw an exception. (See inner exception for details.)
"
我的设置是:
Visual Studio 2017 - 15.6.7
Azure SDK Functinons 1.0.12
Azure功能V1
Azure Web作业工具 - 15.0.40215.0
Azure CLI 1.0.12
以下是我的VS控制台的输出:
func.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\func.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Autofac.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\System.IO.Abstractions.dll'. Cannot find or open the PDB file.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Newtonsoft.Json\9.0.0.0__30ad4fe6b2a6aeed\Newtonsoft.Json.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\ARMClient.Authentication.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\ARMClient.Library.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Colors.Net.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.Azure.WebJobs.Script.dll'. Cannot find or open the PDB file.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.Extensions.Logging.Abstractions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.Azure.WebJobs.Host.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.Azure.WebJobs.Script.WebHost.dll'. Cannot find or open the PDB file.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\FluentCommandLineParser.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'Anonymously Hosted DynamicMethods Assembly'.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\System.Web.Http.SelfHost.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\System.Web.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\System.Net.Http.Formatting.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\System.Web.Http.Cors.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Ignite.SharpNetSH.dll'. Cannot find or open the PDB file.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Internals\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Internals.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Autofac.Integration.WebApi.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Generic.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Azure.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Pusher.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Stripe.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Trello.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.DynamicsCRM.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.MailChimp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Slack.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Bitbucket.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Dropbox.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.WordPress.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.GitHub.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.Salesforce.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.Azure.AppService.Proxy.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.Azure.WebJobs.Extensions.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Receivers.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.Azure.WebJobs.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.WindowsAzure.Storage.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\Microsoft.AspNet.WebHooks.Common.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\System.Reactive.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\System.Reactive.Interfaces.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'func.exe' (CLR v4.0.30319: func.exe): Loaded 'C:\Users\Stanley\AppData\Local\Azure.Functions.Cli\1.0.12\System.Reactive.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[15204] func.exe' has exited with code -1073741510 (0xc000013a).
我试过了: 卸载并重新安装Azure Dev工作负载以及CLI工具 我没有尝试过unistalling /重新安装VS,因为这至少需要半天时间。
我怀疑Azure CLI存在问题
我对Azure Functions + VS感到非常沮丧。 让他的fcking工作真是一场绝对的噩梦!
答案 0 :(得分:2)
解决了问题!
由于Jerry Liu,我设法调试了Azure功能核心工具的源代码。
错误消息证明是牛顿软件相关:
"Could not load type 'Newtonsoft.Json.Converters.ExpandoObjectConverter' from assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'."
所以我只是运行nuget来更新源代码到最新版本的Newtonsoft。 然后我将重建的源代码复制到:
C:\用户[MyUserName输入] \应用程序数据\本地\ AzureFunctionsTools \唱片集\ 1.0.12.1 \ CLI
现在正在运作。
感谢所有参与帮助我解决此事的人!
答案 1 :(得分:1)
我遇到了同样的错误,并将其追溯到Newtonsoft.Json.dll版本中的差异。我通过从GAC卸载10.0版的Newtonsoft.Json解决了这个问题。 (Azure Functions需要9.0。)
因此,在Visual Studio命令提示符下,运行val thm8 = IMP_ANTISYM_RULE thm7 thm6;
,然后在每个版本的DLL上运行gacutil /l | findstr Newtonsoft
,您发现它高于9.0。
如果这不起作用,我建议从源代码运行Azure Functions工具(func.exe)。从gacutil /u
克隆,签出v1.x分支,然后使用https://github.com/Azure/azure-functions-core-tools/
作为命令行参数和您的输出文件夹运行Azure.Functions.Cli项目Azure功能作为工作目录。如果你在调试器中运行它并设置为中断所有CLR异常,你应该能够很快找到你的问题。
答案 2 :(得分:0)
在v2而非v1上为我工作。我必须进入.csproj文件,然后将 AzureFunctionsVersion 添加到PropertyGroup
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>