grpc / grpc/grpc-dotnet

Using dotnet-grpc Throws Exception Adding to a Worker App

Open
#1,609 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
4.5k
Forks
836
Avg merge
6d 3h
Merged PRs (30d)
7

Description

### 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.<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.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__20_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass15_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass24_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__21_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__19_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass13_0.<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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.