Please Login to Continue

Free Software Development Articles.Email List

Advertise Here

Asp.Net Core GRPC Client Error: the type name "GreeterClient" does not exist in the type Greeter

Question: How do you resolve the error: "the type name "GreeterClient" does not exist in the type Greeter" in asp.net core GRPC Server and Client Communications Projects?

Answer: 

  1. Make sure that you have a GRPC Server Project with the correct Proto file in the Protos folder. Proto file lets Dotnet core generate generic code based on the proto file, you will have to make sure that the GrpcService defined is Server or Client based code.

    - Keep in mind that, if you want to generate Grpc Services based on the proto file, you will need to install grpc.tools from NuGet inside your Visual Studio.
       this tool allows the project to build and generate new Services based on the current proto file.

  2. Create a Console .net core 3.1 application that will act as a client to the GRPC Server Application.

    - remember, GRPC protocol has an ability to push data/message in a bidirectional way, unlike the Http Protocol that pushes data in clear text, Grpc Protocol utilizes Protocol Buffers that pushes data in binary form, this makes the Grpc faster than the Http Protocol.

    - Grpc uses Http/2 to push data to the Client in a bidirectional way, meaning, when the data is available on the server and the GRPC Server Application has a request in the pipeline (depending on whether the function responds with a stream of data ), the GRPC Server will push the data to the Client whenever the data is available.

    This is critical for realtime App Communication. It works like SignalR that utilizes Web Sockets to communicate in realtime. GRPC's are special because they communicate, either way (If configured to do so), the client can push data to the Server GRPC App Service, and the Server GRPC App Service can push the data to Client whenever it is available. So, it is important to establish communication between the Client GRPC App and the Server GRPC App through the TLS encrypted channel.

  3. Make sure that GRPC Client App (in this case a Console App for testing purposes) has the required libraries installed. For more information see the reference section for links to helpful sources.

    Install-Package Grpc.Net.Client
    Install-Package Google.Protobuf
    Install-Package Grpc.Tools //This library is also needed on the Server App in order to generate Services if you happen to change the proto file.

  4. Open up .csproj file for your project (Right Click on your Project and navigate to Edit Project File)
  5. Find where it says: 
//Keep in mind that this proto file will be in your Client Application, it should not contain GrpcServices="Server"
//Replace "Server" with "Client" 
<ItemGroup>
    <Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
  </ItemGroup>

6. Replace the "Server" with "Client" since this Protobuf file will be located in the Client App

[Note]: If your service will have more than one rpc function, all will be defined in the nameOfYourProtoFile.proto Service.
              However there can be only one proto file with many rcp functions.

If everthing goes well, you will see the proto folder generated with classes as expected

.net core 3.1 Grpc Erro Client cannot be found.

Call To Action: Please leave a comment to help other Developers resolve their issues if something else helped you.

References: Microsoft Website

https://stackoverflow.com/questions/58884706/visual-studio-2019-net-core-3-grpc-not-generating-service-files

GRPC asp.net core error Technology published
Buy Me Coffee

Was this page helpful?

Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful..



© 2020 - ErnesTech - Privacy