[英]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#.我正在使用 Visual Studio 2017 并编译为 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.解决方案是为每个 .proto 文件设置“构建操作”属性,以使用 protobuf 编译器进行构建。
Do this:做这个:
Your .cs files should now be generated in your folder ./project/MyProject/obj/Debug/netstandard2.0/
folder (or similar destination folder).您的 .cs 文件现在应该在您的文件夹
./project/MyProject/obj/Debug/netstandard2.0/
文件夹(或类似的目标文件夹)中生成。
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" "project/myClass/v1/ mytest .proto" => "project/myClass/v1/ myTest .proto"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.