using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
VS says, The type or namespace name ‘Formatters’ does not exist in the namespace ‘System.Runtime.Serialization’. Well, I should add this reference. Click Project > Add reference > .NET, there I can see only System.Runtime.Serialization, nothing like Formatters.
System.Runtime.Serialization.dll appears to be under c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71\ – there are no Formatters, neither Formatters.Binary there.
How to find this reference?
So apparently Silverlight does not have the
BinaryFormatter. However an open source project exists that may be able to provide similar functionality for you. It is called sharpSerializer. It will work with Silverlight and WP7.I am keeping the other half my answer below, while not appropriate for Silverlight, may be helpful for those that are still missing said reference in other projects, as it should correct it.
For other projects that do not use Silverlight, and have access to the
BinaryFormatteryou may have your target framework set incorrectly.Make sure you are using the full
.NET Framework 4 Profileand not the.NET Framework 4 Client Profilein your project as your target framework. See the image below, you can find these settings in your project’s properties.