【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 @ 2023-02-01 23:21  梦醒江南·Infinite  阅读(174)  评论(0)    收藏  举报