• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[![Nuget](https://img.shields.io/nuget/v/Grpc.svg)](http://www.nuget.org/packages/Grpc/)
2gRPC C#
3=======
4
5A C# implementation of gRPC.
6
7SUPPORTED PLATFORMS
8------------------
9
10- [.NET Core](https://dotnet.github.io/) on Linux, Windows and Mac OS X
11- .NET Framework 4.5+ (Windows)
12- Mono 4+ on Linux, Windows and Mac OS X
13
14PREREQUISITES
15--------------
16
17When using gRPC C# under .NET Core you only need to [install .NET Core](https://www.microsoft.com/net/core).
18
19In addition to that, you can also use gRPC C# with these runtimes / IDEs
20- Windows: .NET Framework 4.5+, Visual Studio 2013, 2015, 2017, Visual Studio Code
21- Linux: Mono 4+, Visual Studio Code, MonoDevelop 5.9+
22- Mac OS X: Mono 4+, Visual Studio Code, Xamarin Studio 5.9+
23
24HOW TO USE
25--------------
26
27**Windows, Linux, Mac OS X**
28
29- Open Visual Studio / MonoDevelop / Xamarin Studio and start a new project/solution (alternatively, you can create a new project from command line with `dotnet` SDK)
30
31- Add the [Grpc](https://www.nuget.org/packages/Grpc/) NuGet package as a dependency (Project options -> Manage NuGet Packages).
32
33- To be able to generate code from Protocol Buffer (`.proto`) file definitions, add the [Grpc.Tools](https://www.nuget.org/packages/Grpc.Tools/) NuGet package that contains Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin.
34
35**Xamarin.Android and Xamarin.iOS (Experimental only)**
36
37See [Experimentally supported platforms](experimental) for instructions.
38
39**Unity (Experimental only)**
40
41See [Experimentally supported platforms](experimental) for instructions.
42
43BUILD FROM SOURCE
44-----------------
45
46You only need to go through these steps if you are planning to develop gRPC C#.
47If you are a user of gRPC C#, go to Usage section above.
48
49**Prerequisites for contributors**
50
51- [dotnet SDK](https://www.microsoft.com/net/core)
52- [Mono 4+](https://www.mono-project.com/) (only needed for Linux and MacOS)
53- Prerequisites mentioned in [BUILDING.md](../../BUILDING.md#pre-requisites)
54  to be able to compile the native code.
55
56**Windows, Linux or Mac OS X**
57
58- The easiest way to build is using the `run_tests.py` script that will take care of building the `grpc_csharp_ext` native library.
59
60  ```
61  # NOTE: make sure all necessary git submodules with dependencies
62  # are available by running "git submodule update --init"
63
64  # from the gRPC repository root
65  $ python tools/run_tests/run_tests.py -l csharp -c dbg --build_only
66  ```
67
68- Use Visual Studio 2017 (on Windows) to open the solution `Grpc.sln` or use Visual Studio Code with C# extension (on Linux and Mac). gRPC C# code has been migrated to
69  dotnet SDK `.csproj` projects that are much simpler to maintain, but are not yet supported by Xamarin Studio or Monodevelop (the NuGet packages still
70  support both `net45` and `netstandard` and can be used in all IDEs).
71
72RUNNING TESTS
73-------------
74
75gRPC C# is using NUnit as the testing framework.
76
77Under Visual Studio, make sure NUnit test adapter is installed (under "Extensions and Updates").
78Then you should be able to run all the tests using Test Explorer.
79
80gRPC team uses a Python script to facilitate running tests for
81different languages.
82
83```
84# from the gRPC repository root
85$ python tools/run_tests/run_tests.py -l csharp -c dbg
86```
87
88DOCUMENTATION
89-------------
90- [API Reference][]
91- [Helloworld Example][]
92- [RouteGuide Tutorial][]
93
94PERFORMANCE
95-----------
96
97For best gRPC C# performance, use [.NET Core](https://dotnet.github.io/) and the Server GC mode `"System.GC.Server": true` for your applications.
98
99THE NATIVE DEPENDENCY
100---------------
101
102Internally, gRPC C# uses a native library written in C (gRPC C core) and invokes its functionality via P/Invoke. The fact that a native library is used should be fully transparent to the users and just installing the `Grpc.Core` NuGet package is the only step needed to use gRPC C# on all supported platforms.
103
104[API Reference]: https://grpc.io/grpc/csharp/api/Grpc.Core.html
105[Helloworld Example]: ../../examples/csharp/helloworld
106[RouteGuide Tutorial]: https://grpc.io/docs/tutorials/basic/csharp.html
107