0

I have just installed .net6 and wanted to try out the gRPC template to check out on their new minimal hosting model. But once I create the project and directly run it, it returns some error.

The grpc project template:

enter image description here

Program.cs

using CloudTemplateBackend.Services;

var builder = WebApplication.CreateBuilder(args);

// Additional configuration is required to successfully run gRPC on macOS.
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682

// Add services to the container.
builder.Services.AddGrpc();

var app = builder.Build();

// Configure the HTTP request pipeline.
app.MapGrpcService<GreeterService>();
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");

app.Run();

The error message:

Severity    Code    Description Project File    Line    Suppression State
Error   CS1061  'IServiceCollection' does not contain a definition for 'AddGrpc' and no accessible extension method 'AddGrpc' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)

Severity    Code    Description Project File    Line    Suppression State
Error   CS1061  'WebApplication' does not contain a definition for 'MapGrpcService' and no accessible extension method 'MapGrpcService' accepting a first argument of type 'WebApplication' could be found (are you missing a using directive or an assembly reference?)

Severity    Code    Description Project File    Line    Suppression State
Error   MSB4064 The "AdditionalProtocArguments" parameter is not supported by the "ProtoCompile" task loaded from assembly: Protobuf.MSBuild, Version=0.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad from the path: 

Severity    Code    Description Project File    Line    Suppression State
Error   MSB4063 The "ProtoCompile" task could not be initialized with its input parameters.
the newbie coder
  • 652
  • 2
  • 8
  • 27
  • Just found out that it is due to the references was not resolved. Restarting visual studio works again.. based on this answer https://stackoverflow.com/questions/31663511/nuget-package-installed-but-references-not-resolved – the newbie coder Nov 18 '21 at 06:03
  • Ensure you have the nuget package **Grpc.AspNetCore.Server**. Then import the the namespace. Add : `using Grpc.AspNetCore.Server;` at the top. More information you find [here](https://learn.microsoft.com/en-us/aspnet/core/grpc/configuration?view=aspnetcore-6.0). – heaxyh Nov 18 '21 at 05:50

0 Answers0