grpc-dotnet icon indicating copy to clipboard operation
grpc-dotnet copied to clipboard

Using dotnet-grpc Throws Exception Adding to a Worker App

Open shawnwildermuth opened this issue 3 years ago • 0 comments

What version of gRPC and what language are you using?

dotnet-grpc 2.42.0+5c8feaec5cda029ee961672bb645de1dd13cccd4

What operating system (Linux, Windows,...) and version?

Windows 10

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

6.0.10.1

What did you do?

If possible, provide a recipe for reproducing the error. Try being specific and include code snippets if helpful. After installing globally, running:

dotnet-grpc add-file ../meterservice.proto

Proto file in child directory not in the same directory. The project is a Worker Service (not a Console app).

What did you expect to see?

Adding required gRPC package reference: Google.Protobuf. Adding required gRPC package reference: Grpc.Net.ClientFactory. Adding required gRPC package reference: Grpc.Tools. Adding file reference ..\meterservice.proto.

What did you see instead?

Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object. at Grpc.Dotnet.Cli.Commands.CommandBase.AddProtobufReference(Services services, String additionalImportDirs, Access access, String file, String url) in //src/dotnet-grpc/Commands/CommandBase.cs:line 177 at Grpc.Dotnet.Cli.Commands.AddFileCommand.AddFileAsync(Services services, Access access, String additionalImportDirs, String[] files) in //src/dotnet-grpc/Commands/AddFileCommand.cs:line 80 at Grpc.Dotnet.Cli.Commands.AddFileCommand.<>c.<<Create>b__1_0>d.MoveNext() in /_/src/dotnet-grpc/Commands/AddFileCommand.cs:line 56 --- End of stack trace from previous location --- at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context) at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context) at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__20_0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<<UseHelp>b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass24_0.<<UseVersionOption>b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseTypoCorrections>b__0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__21_0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__19_0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__11_0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext() --- End of stack trace from previous location --- at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass13_0.<<UseExceptionHandler>b__0>d.MoveNext()

Anything else we should know about your project / environment?

Works if I add the included directory:

dotnet grpc add-file ..\meterreader.proto -i ..

Expected better error message for new users.

shawnwildermuth avatar Feb 12 '22 05:02 shawnwildermuth