![]() |
VOOZH | about |
dotnet add package protobuf-net.Core --version 3.2.56
NuGet\Install-Package protobuf-net.Core -Version 3.2.56
<PackageReference Include="protobuf-net.Core" Version="3.2.56" />
<PackageVersion Include="protobuf-net.Core" Version="3.2.56" />Directory.Packages.props
<PackageReference Include="protobuf-net.Core" />Project file
paket add protobuf-net.Core --version 3.2.56
#r "nuget: protobuf-net.Core, 3.2.56"
#:package protobuf-net.Core@3.2.56
#addin nuget:?package=protobuf-net.Core&version=3.2.56Install as a Cake Addin
#tool nuget:?package=protobuf-net.Core&version=3.2.56Install as a Cake Tool
protobuf-net is a contract based serializer for .NET code, that happens to write data in the "protocol buffers" serialization format engineered by Google. The API, however, is very different to Google's, and follows typical .NET patterns (it is broadly comparable, in usage, to XmlSerializer, DataContractSerializer, etc). It should work for most .NET languages that write standard types and can use attributes.
Change history and pending changes are here.
Build tools to help you use protobuf-net correctly are available via protobuf-net.BuildTools
All stable and some pre-release packages are available on NuGet. CI Builds are available via MyGet (feed URL: https://www.myget.org/F/protobuf-net/api/v3/index.json ).
You can use the following command in the Package Manager Console:
Install-Package protobuf-net
| Package | NuGet Stable | NuGet Pre-release | Downloads | MyGet |
|---|---|---|---|---|
| protobuf-net | 👁 protobuf-net |
👁 protobuf-net |
👁 protobuf-net |
👁 protobuf-net MyGet |
[ProtoContract]
class Person {
[ProtoMember(1)]
public int Id {get;set;}
[ProtoMember(2)]
public string Name {get;set;}
[ProtoMember(3)]
public Address Address {get;set;}
}
[ProtoContract]
class Address {
[ProtoMember(1)]
public string Line1 {get;set;}
[ProtoMember(2)]
public string Line2 {get;set;}
}
Note that unlike XmlSerializer, the member-names are not encoded in the data - instead, you must pick an integer to identify each member. Additionally, to show intent it is necessary to show that we intend this type to be serialized (i.e. that it is a data contract).
This writes a 32 byte file to "person.bin" :
var person = new Person {
Id = 12345, Name = "Fred",
Address = new Address {
Line1 = "Flat 1",
Line2 = "The Meadows"
}
};
using (var file = File.Create("person.bin")) {
Serializer.Serialize(file, person);
}
This reads the data back from "person.bin" :
Person newPerson;
using (var file = File.OpenRead("person.bin")) {
newPerson = Serializer.Deserialize<Person>(file);
}
<= 536870911 and not in the range 19000-19999)Inheritance must be explicitly declared, in a similar way that it must for XmlSerializer and DataContractSerializer. This is done via [ProtoInclude(...)] on each type with known sub-types:
[ProtoContract]
[ProtoInclude(7, typeof(SomeDerivedType))]
class SomeBaseType {...}
[ProtoContract]
class SomeDerivedType {...}
There is no special significance in the 7 above; it is an integer key, just like every [ProtoMember(...)]. It must be unique in terms of SomeBaseType (no other [ProtoInclude(...)] or [ProtoMember(...)] in SomeBaseType can use 7), but does not need to be unique globally.
As an alternative to writing your classes and decorating them, You can generate your types from a .proto schema using protogen;
the protogen tool is available as a zip from that location, or as a "global tool" (multi-platform).
In v2+, everything that can be done with attributes can also be configured at runtime via RuntimeTypeModel. The Serializer.* methods are basically just shortcuts to RuntimeTypeModel.Default., so to manipulate the behaviour of Serializer., you must configure RuntimeTypeModel.Default.
I try to be responsive to Stack Overflow questions in the protobuf-net tag, issues logged on GitHub, , etc. I don't currently offer a paid support channel. If I've helped you, feel free to buy me a coffee or see the "Sponsor" link at the top of the GitHub page.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on protobuf-net.Core:
| Package | Downloads |
|---|---|
|
protobuf-net
Provides simple access to fast and efficient "Protocol Buffers" serialization from .NET applications |
|
|
protobuf-net.Reflection
ProtoBuf DSL (proto2 / proto3) and descriptor tools for protobuf-net |
|
|
protobuf-net.Grpc.Reflection
Package Description |
|
|
Hiperspace
Base assembly of HiperSpaces |
|
|
Protobuf.Grpc.Reflection
Package Description |
Showing the top 17 popular GitHub repositories that depend on protobuf-net.Core:
| Repository | Stars |
|---|---|
|
Valkirie/HandheldCompanion
ControllerService
|
|
|
ape-byte/DouyinBarrageGrab
基于系统代理的抖音弹幕wss抓取程序,能够获取所有数据来源,包括chrome,抖音直播伴侣等,可进行进程过滤
|
|
|
protobuf-net/protobuf-net.Grpc
GRPC bindings for protobuf-net and grpc-dotnet
|
|
|
rasta-mouse/SharpC2
Command and Control Framework written in C#
|
|
|
yswenli/SAEA
SAEA.Socket is a high-performance IOCP framework TCP based on dotnet standard 2.0; Src contains its application test scenarios, such as websocket,rpc, redis driver, MVC WebAPI, lightweight message server, ultra large file transmission, etc. SAEA.Socket是一个高性能IOCP框架的 TCP,基于dotnet standard 2.0;Src中含有其应用测试场景,例如websocket、rpc、redis驱动、MVC WebAPI、轻量级消息服务器、超大文件传输等
|
|
|
CrowdStrike/sccmhound
A BloodHound collector for Microsoft Configuration Manager
|
|
|
MobiFlight/MobiFlight-Connector
MobiFlight is an open source project that allows you to create your own home cockpit for your favorite flight simulator in a flexible, affordable and extremely user-friendly way.
|
|
| Bannerlord-Coop-Team/BannerlordCoop | |
|
geel9/SteamAuth
A C# library that provides vital Steam Mobile Authenticator functionality
|
|
|
FromDarkHell/BL3SaveEditor
A desktop based save and profile editor for Borderlands 3
|
|
|
zhongkaifu/Seq2SeqSharp
Seq2SeqSharp is a tensor based fast & flexible deep neural network framework written by .NET (C#). It has many highlighted features, such as automatic differentiation, different network types (Transformer, LSTM, BiLSTM and so on), multi-GPUs supported, cross-platforms (Windows, Linux, MacOS), multimodal model for text and images and so on.
|
|
|
yswenli/GFF
GFF is a imitation QQ communication project, based on high IOCP. GFF是模仿QQ通讯项目,通信基于SAEA.MessageSocket、SAEA.Http、SAEA.MVC实现
|
|
|
dje-dev/Ceres
Ceres - an MCTS chess engine for research and recreation
|
|
|
sp0ok3r/Mercury
Mercury is a powerful tool for Steam users built on SteamKit2, offering advanced features for managing accounts, chats, and interactions.
|
|
|
beetlex-io/BeetleX-Samples
BeetleX micro services framework (tcp webapi websocket and xrpc) samples
|
|
|
achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies
Reimagining the SDA application in better shape.
|
|
|
Ginger-Automation/Ginger
Ginger Automation IDE
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.3.0-g6785ecbb35 | 11,389 | 7/12/2025 |
| 3.2.56 | 8,253,886 | 7/31/2025 |
| 3.2.55 | 96,023 | 7/27/2025 |
| 3.2.52 | 15,010,927 | 4/11/2025 |
| 3.2.46 | 3,930,277 | 1/24/2025 |
| 3.2.45 | 9,256,862 | 10/23/2024 |
| 3.2.30 | 23,928,208 | 9/27/2023 |
| 3.2.26 | 6,700,973 | 5/25/2023 |
| 3.2.16 | 2,994,398 | 3/17/2023 |
| 3.2.12 | 16,774,594 | 3/4/2023 |
| 3.2.8 | 119,600 | 2/27/2023 |
| 3.2.0 | 227,954 | 2/20/2023 |
| 3.1.33 | 4,114,113 | 1/30/2023 |
| 3.1.26 | 1,977,632 | 12/16/2022 |
| 3.1.25 | 2,439,937 | 11/9/2022 |
| 3.1.22 | 1,778,657 | 9/21/2022 |
| 3.1.17 | 4,236,835 | 6/26/2022 |
| 3.1.4 | 3,192,669 | 5/10/2022 |