Closed gabesmsft closed 3 years ago
I fixed this issue by changing this
var host = new HostBuilder()
.ConfigureAppConfiguration(c => {})
.ConfigureFunctionsWorker((c, b) =>
{
b.UseFunctionExecutionMiddleware();
})
.Build();
To this
var host = new HostBuilder()
.ConfigureAppConfiguration(c => {
c.AddCommandLine(args);
})
.ConfigureFunctionsWorker((c, b) =>
{
b.UseFunctionExecutionMiddleware();
})
.Build();
Didnt really dig into why, hope it helps
I am already using the ConfigureAppConfiguration(c =>{c.AddCommandLine(args);}) lines (it was already part of this github repo when I downloaded the code), but am hitting the described issue in Visual Studio all the same, but thanks for your reply.
I have this same issue, first I created a new project and followed the readme. Then I started hitting this issue. So I thought perhaps I did something wrong, cloned the project, tried to launch that as well and....
The "fix" mentioned by @Spaceman1861 did not work for me, no matter what combo of configure I did or didn't use.
Edit with version infos:
Using Core Tools Version: 3.0.3160 Commit hash: 00aa7f43cc5c5f15241b5e6e5363256f19ceb990 Visual Studio 16.8.3 & Tried Visual Studio 16.9.0 Preview 2.0
And my dotnet --info says:
.NET SDK (reflecting any global.json):
Version: 5.0.200-preview.20601.7
Commit: b3b934bbf2
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.200-preview.20601.7\
Host (useful for support):
Version: 5.0.1
Commit: b02e13abab
.NET SDKs installed:
2.1.509 [C:\Program Files\dotnet\sdk]
2.1.802 [C:\Program Files\dotnet\sdk]
2.2.402 [C:\Program Files\dotnet\sdk]
5.0.101 [C:\Program Files\dotnet\sdk]
5.0.200-preview.20601.7 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Solved:
You can not debug the application directly using Visual Studio.
You can only start by using the command line func host start
. If you do not, Visual Studio will try to debug the application directly instead of serving it using an out-of-process host that starts it.
I think this issue can be closed as @gabesmsft and me not understanding / reading the readme good enough.
I understand that the Visual Studio debugging experience is still being worked on, but I want to report this issue in case it isn't a known issue. The following issue happens even when I uncomment the Debugger.Launch() statement. The same project works as expected when starting from command line or VS Code.
Am using the sample code provided in this GitHub repo, as-is. Am hitting a System.ArgumentNullException during host startup issue that only happens in Visual Studio when running the following part of the sample code: https://github.com/Azure/azure-functions-dotnet-worker-preview/blob/main/FunctionApp/Program.cs#L22-L25
This issue can be consistently reproduced even on a fresh new Windows machine with the following software installed: Visual Studio 2019: version 16.8.3 Microsoft.NET SDK 5.0.100 x64 Azure Functions Core Tools 3.0.3160 (x64)
Here is the full stack trace of the exception: System.ArgumentNullException HResult=0x80004003 Message=Value cannot be null. (Parameter 'value') Source=Google.Protobuf StackTrace: at Google.Protobuf.ProtoPreconditions.CheckNotNull[T](T value, String name) at Microsoft.Azure.WebJobs.Script.Grpc.Messages.StartStream.set_WorkerId(String value) in D:\a\1\s\src\DotNetWorker\obj\Release\net5.0\FunctionRpc.cs:line 1414 at Microsoft.Azure.Functions.Worker.WorkerHostedService.d9.MoveNext() in D:\a\1\s\src\DotNetWorker\WorkerHostedService.cs:line 48
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Azure.Functions.Worker.WorkerHostedService.d 7.MoveNext() in D:\a\1\s\src\DotNetWorker\WorkerHostedService.cs:line 37
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Extensions.Hosting.Internal.Host.d9.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.d 4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.d4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at FunctionApp.Program.d 0.MoveNext() in C:\temp\FunctionsNet5\FunctionApp\Program.cs:line 32