MessagePack implementation for Common Language Infrastructure /[C#]
yfakariya Merge pull request #282 from ShrenikOne/master
Issue #278: Support skipping of Member for a Type on serialization without MessagePackIgnoreAttribute
Latest commit e6b43e4 Jun 14, 2018
Failed to load latest commit information.
.nuget Update nuget.exe Aug 26, 2017
asset Fix unity project folder. May 1, 2018
build Bump version. Jun 13, 2018
samples Fix sample. Nov 11, 2017
src Merge pull request #282 from ShrenikOne/master Jun 14, 2018
test Merge pull request #282 from ShrenikOne/master Jun 14, 2018
tools rebuild mpu Apr 30, 2018
.editorconfig Tweak .editorconfig. #281 Feb 12, 2018
.gitignore Exclude AppPackages/ subdirectory. Jun 4, 2016
AUTHORS.txt Restructure directories to bring up CLI tree as top. May 23, 2012
BuildNote.txt Update API documentation related notes. Oct 6, 2013
CHANGES.txt Revise change log. Jun 13, 2018 Fix Jul 15, 2016
Directory.Build.props Consolidate project properties. Aug 26, 2017
LICENSE.txt Restructure directories to bring up CLI tree as top. May 23, 2012
MsgPack.Common.props Refactor Xamarin test projects. Feb 12, 2018
MsgPack.Windows.sln Fix UAP build setting. #186 Sep 26, 2017
MsgPack.Xamarin.sln Fix Xamarin.Android test projects. Mar 11, 2018
MsgPack.compats.sln Migrate .NET 3.5 projects. Apr 12, 2017
MsgPack.mono.sln Unify .NET build and Mono build. Nov 24, 2013
MsgPack.nuspec Add symbol package with source code build. May 3, 2017
MsgPack.shfbproj Update help file build configuration. Aug 15, 2015
MsgPack.sl5.shfbproj Add Sandcastle files. Aug 15, 2012
MsgPack.sln Update solution. Aug 26, 2017 Merge pull request #294 from msgpack/fix/build-and-test-stability Jun 13, 2018
SOURCES.txt Fix txt file encodings. May 4, 2013
Sync.Test.json Refactor Xamarin test projects. Feb 12, 2018
Sync.json Synchronize project files. Sep 23, 2017
SyncProjects.bat Add new sync projects tool. Aug 26, 2017 Add documents. Jul 20, 2015
appveyor-debug.yml Remove Android SDK update Oct 29, 2017
appveyor-debug35-codedom.yml Separate .NET 3.5 CodeDOM test from other .NET 3.5 test to avoid AppV… Jun 13, 2018
appveyor-debug35.yml Separate app veyor unit test jobs. Dec 17, 2017
appveyor-release.yml Remove Android SDK update Oct 29, 2017
global.json Add CoreCLR unit test project w/ NUnit. Jun 26, 2016
msgpack.ico Add icon. Jul 21, 2013

MessagePack for CLI

Build status release Build status debug Build status debug net35 Build status debug net35 CodeDOM

What is it?

This is MessagePack serialization/deserialization for CLI (Common Language Infrastructure) implementations such as .NET Framework, Silverlight, Mono (including Moonlight.) This library can be used from ALL CLS compliant languages such as C#, F#, Visual Basic, Iron Python, Iron Ruby, PowerShell, C++/CLI or so.


You can serialize/deserialize objects as following:

  1. Create serializer via MessagePackSerializer.Get generic method. This method creates dependent types serializers as well.
  2. Invoke serializer as following: ** Pack method with destination Stream and target object for serialization. ** Unpack method with source Stream.
// Creates serializer.
var serializer = MessagePackSerializer.Get<T>();
// Pack obj to stream.
serializer.Pack(stream, obj);
// Unpack from stream.
var unpackedObject = serializer.Unpack(stream);
' Creates serializer.
Dim serializer = MessagePackSerializer.Get(Of T)()
' Pack obj to stream.
serializer.Pack(stream, obj)
' Unpack from stream.
Dim unpackedObject = serializer.Unpack(stream)

For production environment, you should instantiate own SerializationCOntext and manage its lifetime. It is good idea to treat it as singleton because SerializationContext is thread-safe.


  • Fast and interoperable binary format serialization with simple API.
  • Generating pre-compiled assembly for rapid start up.
  • Flexible MessagePackObject which represents MessagePack type system naturally.

Note: AOT support is limited yet. Use serializer pre-generation with mpu -s utility or API.
If you do not pre-generated serializers, MsgPack for CLI uses reflection in AOT environments, it is slower and it sometimes causes AOT related error (ExecutionEngineException for runtime JIT compilation).


See wiki


  • Binary files distributed via the NuGet package MsgPack.Cli.
  • You can extract binary (DLL) file as following:
    1. Download *.zip file from GitHub Release page.
    2. Extract it.
    3. Under the bin directory, binaries are there!
    • For mono, you can use net461 or net35 drops as you run with.
    • For Unity, unity3d drop is suitable.

How to build

For .NET Framework

  1. Install Visual Studio 2017 (Community edition is OK) and 2015 (for MsgPack.Windows.sln).

    • You must install .NET Framework 3.5, 4.x, .NET Core, and Xamarin dev tools to build all builds successfully. If you do not want to install options, edit <TargetFrameworks> element in *.csproj files to exclude platforms you want to exclude.
  2. Install latest .NET Core SDK.

  3. Run with Visual Studio Developer Command Prompt:

    msbuild MsgPack.sln /t:Restore msbuild MsgPack.sln

Or (for Unity 3D drops):

msbuild MsgPack.compats.sln /t:Restore
msbuild MsgPack.compats.sln

Or (for Windows Runtime/Phone drops and Silverlight 5 drops):

msbuild MsgPack.Windows.sln /t:Restore
msbuild MsgPack.Windows.sln

Or (for Xamarin unit testing, you must have Xamarin Business or upper license and Mac machine on the LAN to build on Windows):

msbuild MsgPack.Xamarin.sln /t:Restore
msbuild MsgPack.Xamarin.sln

Or open one of above solution files in your IDE and run build command in it.

For Mono

  1. Install latest Mono and .NET Core SDK.
  2. Now, you can build MsgPack.sln and MsgPack.Xamarin.sln with above instructions and msbuild in latest Mono. Note that xbuild does not work because it does not support latest csproj format.

Own Unity 3D Build

First of all, there are binary drops on github release page, you should use it to save your time.
Because we will not guarantee source code organization compatibilities, we might add/remove non-public types or members, which should break source code build.
If you want to import sources, you must include just only described on MsgPack.Unity3D.csproj.
If you want to use ".NET 2.0 Subset" settings, you must use just only described on MsgPack.Unity3D.CorLibOnly.csproj file, and define CORLIB_ONLY compiler constants.

Xamarin Android testing

If you run on Windows, it is recommended to use HXM instead of Hyper-V based emulator.
You can disable Hyper-V from priviledged (administrator) powershell as follows:

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor

If you want to use Hyper-V again (such as for Docker for Windows etc.), you can do it by following in priviledged (administrator) powershell:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor

Xamarin Android Trouble shooting tips

  • Javac shows compilation error.
    • Rebuild the test project and try it run again.

Xamarin iOS testing

You must create provisoning profiles in your MacOS devices.
See Xamarin documents about provisining for details.

There are bundle IDs of current iOS tests:

  • org.msgpack.msgpack-cli-xamarin-ios-test
  • org.msgpack.msgpack-cli-xamarin-ios-test-packer
  • org.msgpack.msgpack-cli-xamarin-ios-test-unpacker
  • org.msgpack.msgpack-cli-xamarin-ios-test-unpacking
  • org.msgpack.msgpack-cli-xamarin-ios-test-timestamp
  • org.msgpack.msgpack-cli-xamarin-ios-test-arrayserialization
  • org.msgpack.msgpack-cli-xamarin-ios-test-mapserialization

Note that some reflection based serializer tests failed with AOT related limitation.

Xamarin iOS Trouble shooting tips

See Xamarin's official trouble shooting docs first.

  • An error occurred while running unit test project.
    • Rebuild the project and rerun it. Or, login your Mac again, ant retry it.
  • It is hard to read English.
    • You can read localized Xamarin docs with putting {region}-{lang} as the first component of URL path such as

See also