# Grpc.Core.RpcException: Status(StatusCode="Unimplemented", Detail="方法 'YourMethod' 未实现。")

- **ID:** `dotnet/grpc-unimplemented-service`
- **领域:** dotnet
- **类别:** protocol_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

gRPC 客户端调用了服务器未注册或未实现的方法，通常是由于缺少服务绑定或 proto 编译错误。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Grpc.AspNetCore 2.57.0 | active | — | — |
| Google.Protobuf 3.24.0 | active | — | — |
| Grpc.Tools 2.57.0 | active | — | — |

## 解决方案

1. ```
   使用 'dotnet grpc' 或 'protoc' 工具从同一 .proto 文件重新生成客户端和服务器存根。确保服务器启动代码映射服务：'app.UseEndpoints(endpoints => { endpoints.MapGrpcService<MyServiceImpl>(); });'
   ```
2. ```
   验证服务已在 DI 容器中注册：'services.AddGrpc();' 和 'services.AddScoped<MyServiceImpl>();'，然后在端点中映射。
   ```

## 无效尝试

- **** — Checking only the client-side proto file while the server uses an older version causes mismatch; both must be regenerated from the same .proto. (70% 失败率)
- **** — Restarting the server without recompiling the service code does not register new methods; the error persists. (85% 失败率)
- **** — Assuming the method name is case-insensitive in gRPC leads to wrong endpoint calls; gRPC method names are case-sensitive. (60% 失败率)
