Search code examples
azurevisual-studio-2017azure-functionsazure-functions-core-tools

Can't Debug Azure Function - Visual Studio 2017


I create a brand new project using the Azure Functions tool with V1 of Azure functions:

enter image description here

I then hit F5 and get the yellow lightning bolt and then an error message:

"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.)"

enter image description here

My settings are:

Visual Studio 2017 - 15.6.7

Azure SDK Functinons 1.0.12

Azure Function V1

Azure Web Job Tools - 15.0.40215.0

Azure CLI 1.0.12

Here are my outputs from my VS console:

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).

I have tried: Uninstalling and reinstalling the Azure Dev workload and also the CLI tools I haven't tried unistalling/reinstaling VS as this will take at least half a day.

I suspect the problem lies with the Azure CLI

I am getting really frustrated with Azure Functions + VS. It is an absolute nightmare to get his fcking thing working !


Solution

  • Problem Solved !

    I managed to debug the source code for the Azure Function Core Tools thanks to Jerry Liu.

    The error message turned out to be Newtonsoft related:

    "Could not load type 'Newtonsoft.Json.Converters.ExpandoObjectConverter' from assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'."
    

    So I just ran nuget to the update the source code to the latest version of Newtonsoft. Then I copied the rebuilt source code to:

    C:\Users[MyUserName]\AppData\Local\AzureFunctionsTools\Releases\1.0.12.1\cli

    and it is now working.

    Thanks to all involved in helping me resolve this !