ServiceModel.Grpc.SelfHost
1.13.0
See the version list below for details.
dotnet add package ServiceModel.Grpc.SelfHost --version 1.13.0
NuGet\Install-Package ServiceModel.Grpc.SelfHost -Version 1.13.0
<PackageReference Include="ServiceModel.Grpc.SelfHost" Version="1.13.0" />
<PackageVersion Include="ServiceModel.Grpc.SelfHost" Version="1.13.0" />
<PackageReference Include="ServiceModel.Grpc.SelfHost" />
paket add ServiceModel.Grpc.SelfHost --version 1.13.0
#r "nuget: ServiceModel.Grpc.SelfHost, 1.13.0"
#:package ServiceModel.Grpc.SelfHost@1.13.0
#addin nuget:?package=ServiceModel.Grpc.SelfHost&version=1.13.0
#tool nuget:?package=ServiceModel.Grpc.SelfHost&version=1.13.0
ServiceModel.Grpc.SelfHost
ServiceModel.Grpc enables applications to communicate with gRPC services using a code-first approach (no .proto files), helps to get around limitations of gRPC protocol like "only reference types", "exact one input", "no nulls", "no value-types". Provides exception handling. Helps to migrate existing WCF solution to gRPC with minimum effort.
ServiceModel.Grpc.SelfHost is package with code-first extensions for Grpc.Core.Server.
Declare a service contract and implement service
A service contract is an interface decorated with the ServiceContract attribute. Interface methods decorated with the OperationContract attribute are treated as gRPC operations.
For example, following ICalculator contract with unary Sum operation and client streaming MultiplyBy operation:
[ServiceContract]
public interface ICalculator
{
[OperationContract]
Task<long> Sum(long x, int y, int z, CancellationToken token = default);
[OperationContract]
ValueTask<(int Multiplier, IAsyncEnumerable<int> Values)> MultiplyBy(IAsyncEnumerable<int> values, int multiplier, CancellationToken token = default);
}
internal sealed class Calculator : ICalculator
{
public Task<long> Sum(long x, int y, int z, CancellationToken token) => x + y + z;
public ValueTask<(int Multiplier, IAsyncEnumerable<int> Values)> MultiplyBy(IAsyncEnumerable<int> values, int multiplier, CancellationToken token)
{
var multiplicationResult = DoMultiplication(values, multiplier, token);
return new ValueTask<(int, IAsyncEnumerable<int>)>((multiplier, multiplicationResult));
}
private static async IAsyncEnumerable<int> DoMultiplication(IAsyncEnumerable<int> values, int multiplier, [EnumeratorCancellation] CancellationToken token)
{
await foreach (var value in values.WithCancellation(token))
{
yield return value * multiplier;
}
}
}
Configure service
Create Server and add service to the routing pipeline.
Grpc.Core.Server server = new Server
{
Ports = { new ServerPort("localhost", 5000, ServerCredentials.Insecure) }
};
// bind the service
server.Services.AddServiceModelTransient(() => new Calculator());
server.Start();
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Grpc.Core (>= 2.46.6)
- ServiceModel.Grpc (>= 1.13.0)
-
.NETStandard 2.0
- Grpc.Core (>= 2.46.6)
- ServiceModel.Grpc (>= 1.13.0)
-
.NETStandard 2.1
- Grpc.Core (>= 2.46.6)
- ServiceModel.Grpc (>= 1.13.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ServiceModel.Grpc.SelfHost:
| Package | Downloads |
|---|---|
|
MF40.Silo
Orleans Silo |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on ServiceModel.Grpc.SelfHost:
| Repository | Stars |
|---|---|
|
6bee/Remote.Linq
Simply LINQ your remote resources...
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.19.0 | 185 | 11/9/2025 |
| 1.18.0 | 191 | 10/2/2025 |
| 1.17.0 | 235 | 8/31/2025 |
| 1.16.0 | 245 | 6/29/2025 |
| 1.15.0 | 240 | 6/15/2025 |
| 1.14.0 | 2,909 | 4/18/2025 |
| 1.13.0 | 475 | 2/2/2025 |
| 1.12.0 | 213 | 1/12/2025 |
| 1.11.1 | 1,779 | 11/30/2024 |
| 1.11.0 | 220 | 11/23/2024 |
| 1.10.1 | 1,172 | 10/19/2024 |
| 1.9.1 | 332 | 9/29/2024 |
| 1.9.0 | 315 | 7/21/2024 |
| 1.8.3 | 1,020 | 5/18/2024 |
| 1.8.2 | 284 | 3/2/2024 |
| 1.8.1 | 788 | 2/13/2024 |
| 1.8.0 | 428 | 1/7/2024 |
| 1.7.0 | 253 | 12/24/2023 |
| 1.6.1 | 300 | 11/25/2023 |
| 1.6.0 | 373 | 9/9/2023 |
| 1.5.2 | 1,745 | 6/25/2023 |
| 1.5.1 | 979 | 5/1/2023 |
| 1.5.0 | 496 | 3/7/2023 |
| 1.4.13 | 461 | 12/19/2022 |
| 1.4.12 | 653 | 11/19/2022 |
| 1.4.11 | 514 | 10/23/2022 |
| 1.4.10 | 745 | 8/14/2022 |
| 1.4.9 | 514 | 7/23/2022 |
| 1.4.8 | 627 | 5/29/2022 |
| 1.4.7 | 519 | 5/21/2022 |
| 1.4.6 | 1,784 | 4/3/2022 |
| 1.4.5 | 555 | 3/26/2022 |
| 1.4.4 | 574 | 3/12/2022 |
| 1.4.3 | 653 | 2/5/2022 |
| 1.4.2 | 28,366 | 1/22/2022 |
| 1.4.1 | 392 | 1/8/2022 |
| 1.4.0 | 3,075 | 11/26/2021 |
| 1.3.2 | 519 | 11/5/2021 |
| 1.3.1 | 2,754 | 10/10/2021 |
| 1.3.0 | 902 | 7/31/2021 |
| 1.2.1 | 482 | 6/12/2021 |
| 1.2.0 | 543 | 6/6/2021 |
| 1.1.9 | 496 | 5/8/2021 |
| 1.1.8 | 664 | 3/28/2021 |
| 1.1.7 | 602 | 1/3/2021 |
| 1.1.6 | 562 | 12/13/2020 |
| 1.1.5 | 613 | 11/21/2020 |
| 1.1.4 | 708 | 10/11/2020 |
| 1.1.3 | 757 | 9/13/2020 |
| 1.1.2 | 607 | 8/26/2020 |
| 1.1.1 | 645 | 6/21/2020 |
| 1.1.0 | 688 | 5/10/2020 |
| 1.0.1 | 700 | 5/1/2020 |
| 1.0.0 | 707 | 4/23/2020 |
| 1.0.0-pre2 | 538 | 4/18/2020 |
| 1.0.0-pre1 | 525 | 4/16/2020 |