Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The name 'GrpcClient' does not exist in the current context GrpcGreeterClient #14170

Closed
VinceJSV opened this issue Sep 6, 2019 — with docs.microsoft.com · 15 comments · Fixed by #21732
Closed

The name 'GrpcClient' does not exist in the current context GrpcGreeterClient #14170

VinceJSV opened this issue Sep 6, 2019 — with docs.microsoft.com · 15 comments · Fixed by #21732
Labels
gRPC Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

Copy link

VinceJSV commented Sep 6, 2019

After pasting the code into program.cs in the Greeter client project I get compiler error "The name 'GrpcClient' does not exist in the current context GrpcGreeterClient". I think that this is because no classes are generated by the build process after adding the item group to the project file. No idea why, the project file was edited correctly.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added the Source - Docs.ms Docs Customer feedback via GitHub Issue label Sep 6, 2019
Copy link
Author

VinceJSV commented Sep 6, 2019

As work around suggested RobinKetting fixed the issue for now. Had to uninstall the current Grpc.Net.Client package and issue the following command in the PMC "Install-Package Grpc.Net.Client -version 0.1.22-pre2"

@Rick-Anderson
Copy link
Contributor

@VinceJSV thanks for the update. When ASP.NET Core 3.0 GA's, this shouldn't be a problem.

@JamesNK - do we need to add a note for this problem or is the issue discoverable enough?

Copy link

I just ran into the same problem. Make sure Grpc.AspNetCore is only installed on the Server project. If it is installed across the whole solution then it conflicts with Grpc.Net.Client on the Client project and prevents the Client project from installing correctly.

@ihorbond
Copy link

ihorbond commented Dec 16, 2019

@Rick-Anderson why is this issue closed ?! I have similar problem and installing earlier version of grpc client actually makes it worse cause now the GrpcChannel namespace is missing.

@Rick-Anderson
Copy link
Contributor

@ihorbond the cause of the problem and solution are in this issue.

@hjy1210
Copy link

hjy1210 commented Jan 4, 2020

@ihorbond

I ran into the same problem.

After inspect the GrpcGreeterClient.csproj, I found a strange node as follows:

<ItemGroup>
    <Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
</ItemGroup>

After delete it, rebuild the project, the problem is gone.

@chrisbiles
Copy link

To anyone that might still have the above mentioned problem, make 100% sure that your PMC "Default Project" setting is set to GrpcGreeterClient when issuing the following commands:

Install-Package Grpc.Net.Client
Install-Package Google.Protobuf
Install-Package Grpc.Tools

If not, you will have the aforementioned problem. I just figured it out today that I was doing something that dumb and wondering why the GrpcClient was not being created. Hope this helps.

Chris

@Jezuz85
Copy link

Jezuz85 commented Dec 28, 2020

in my file GrpcGreeterClient.csproj delete this part

	<ItemGroup>
		<Protobuf Include="Protos\greet.proto" GrpcServices="Client" />
	</ItemGroup>

compile and then add the line again, and it worked without issue

@Joaostinglin
Copy link

the solution from Jezuz85, works perfectly on my end. Thank you so much!

@Rick-Anderson Rick-Anderson reopened this Mar 9, 2021
@Rick-Anderson
Copy link
Contributor

@JamesNK should I mention this in the tutorial? @wadepickett on testing did you see this?

@JamesNK
Copy link
Member

JamesNK commented Mar 9, 2021

Removing and adding the same text from a csproj shouldn't have any impact. I'm not sure what the issue is that people are encountering.

@wadepickett
Copy link
Contributor

wadepickett commented Mar 9, 2021

@Rick-Anderson, I think you are referring to the test I did for #21657. (Sorry just saw your question from 4 hours ago)

It looked like there was issue around renaming the namespace in the greet.proto to "GrpcGreeterClient" which was fixed in the doc instructions but was not updated in the current client downloadable sample: The namespace inside the greet.proto file for the client sample project's namespace should be:
option csharp_namespace = "GrpcGreeterClient";
but incorrectly, the client sample was showing the original namespace for the server app greet.proto:
option csharp_namespace = "GrpcGreeter";

@JamesNK
Copy link
Member

JamesNK commented Mar 9, 2021

Fix #21732

@eyal7773
Copy link

eyal7773 commented Jun 1, 2022

How to solve :

  1. Verify again that inside your client app, in Greeter.proto file - this row include the "Client" at the end.
option csharp_namespace = "GrpcGreeterClient";

  1. Clean the project.

  2. Rebuild

  3. Solved, now this method Greeter.GreeterClient will be exists.

@caiomjc
Copy link

caiomjc commented Jun 3, 2023

The problem, for me, was the csproj.
When I copied the greet.proto from server project to client project, the csproj file added by itself the ItemGroup like this:

<ItemGroup> <Protobuf Include="Protos\greet.proto" GrpcServices="Server" /> </ItemGroup>

Just replaced the "Server" for "Client" and all worked just fine.
In the end, should be like this:

<ItemGroup> <Protobuf Include="Protos\greet.proto" GrpcServices="Client" /> </ItemGroup>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gRPC Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.