简体   繁体   中英

How to fix "The type of namespace name "Fault" does not exist in the namespace" for gRPC and C#?

I've defined a lot of types and methods (messages and services in proto-lingo) and got stuck on this problem. Sometimes when I make changes I get this very unhelpful error message.

The type of namespace name "Fault" does not exist in the namespace 'MyApp.MyDomain' (are you missing an assembly reference?) 

I'm using Visual Studio 2017 and compile to C#.

I'm answering my own question because I get a feeling this is a common problem. It's also hard enough to figure out because the error message is (although helpful) very general. Ie you get the same error message all the time for various reasons.

The solution was to set the "Build Action"-property for each .proto file to build using the protobuf compiler.

Do this:

  1. Right click on your .proto file in the Visual Studio solution explorer.
  2. Choose "Properties"
  3. Change "Build action" to "Protobuf compiler"

Your .cs files should now be generated in your folder ./project/MyProject/obj/Debug/netstandard2.0/ folder (or similar destination folder).

I ran into this but in my situation, I had an import statement. The import statement is case sensitive.

"project/myClass/v1/ mytest .proto" => "project/myClass/v1/ myTest .proto"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM