"Turn" http://blog.csdn.net/shantsc/article/details/50729402
Protobuf C # version is divided into two versions, one is protobuf-net and the other is Protobuf-csharp-sport
One, protobuf-net version
Step 1. Edit 111.proto file Follow Google format message A class name required must be assigned a field
1 Message Person2 { 3RequiredstringName=1;4Required Int32 id=2;5OptionalstringEmail=3;6 7 enumPhonetype8 {9monile=0;TenHome=1; Onework=2; A } -}
Step 2. Compile the protobuf-net and then compile the references in the Protogen Protogen.exe
Step 3: Under DOS CD to Protogen.exe then-i:111.proto-o:111.cs-ns:myproto
Below is another version of the
Second, protobuf-csharp-sport version
The steps are as follows:
1. Download the Protobuf-csharp-port package from the http://code.google.com/p/protobuf-csharp-port/website first, The version I downloaded is: protobuf-csharp-port-2.4.1.473-release-binaries.
2. After extracting the above package, remove the Protogen.exe.config,protoc.exe,protogen.exe and Google.ProtocolBuffers.dll files into the D:\protoc folder.
(The D:\protoc folder is self-built).
3. Open the command prompt (my windows7 system), first use the CD C: \ command in the doc command to go to the B-drive, and then enter D-Carriage, go to D-Drive, and then CD Protoc go to the D:\protoc folder. (very meticulous ha, even a bit verbose ha, but I have to use Google for every time ~)
4. Add the Protobuf files that need to be converted to C # into the D:\protoc folder, for example, we want to transfer addressbook.proto files.
5. At the command prompt, enter:
Protoc--descriptor_set_out=addressbook.protobin--include_imports Addressbook.proto
(After the above command, you will find a Addressbook.protobin file in the D Protoc folder)
Next:
Protogen Addressbook.protobin Enter
After the above command, the D disk Protoc folder more than a AddressBook.cs file, yes, this is the most attention to the ultimate goal file.
It's done, oh, it's simple.
6. Import the CS file into the project and you can use the ~
(ii) C # use of Protobuf