【gRPC】.NET 6 WPF gRPC client 无法找到命名空间生成项目失败

基于.NET 6的WPF项目作为gRPC客户端,生成项目时出错:

1>D:\projects\aasp_pc_soft\AutonomicAnalysisSystemForPressurePellets\AutoAnalysisSystemClientTest\AutoAnalysisSystemClientTest\MainWindow.xaml.cs(1,7,1,31): error CS0246: 未能找到类型或命名空间名“AutoAnalysisSystemServer”(是否缺少 using 指令或程序集引用?)
1>已完成生成项目“AutoAnalysisSystemClientTest_lobubfhn_wpftmp.csproj”的操作 - 失败。

 

解决方法:

c# - gRPC erros in WPF .NET Core - Stack Overflow

 


Add this line in WPF Project File, file with extension "*.csproj", specifically in the tag <PropertyGroup> and rebuild:

<CoreCompileDependsOn>$(CoreCompileDependsOn);Protobuf_Compile</CoreCompileDependsOn>

It will look like this in the .csproj file:

"..."
    <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net6.0-windows</TargetFramework>
        <Nullable>enable</Nullable>
        <UseWPF>true</UseWPF>
        <CoreCompileDependsOn>$(CoreCompileDependsOn);Protobuf_Compile</CoreCompileDependsOn>
      </PropertyGroup>
"..."

 

posted @   梦醒江南·Infinite  阅读(144)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
点击右上角即可分享
微信分享提示