해결방법 :
01 |
sealed class AllowAllAssemblyVersionsDeserializationBinder : System.Runtime.Serialization.SerializationBinder |
02 |
{ |
03 |
public override Type BindToType( string assemblyName, string typeName) |
04 |
{ |
05 |
Type typeToDeserialize = null ; |
06 |
07 |
String currentAssembly = Assembly.GetExecutingAssembly().FullName; |
08 |
09 |
// In this case we are always using the current assembly |
10 |
assemblyName = currentAssembly; |
11 |
12 |
// Get the type using the typeName and assemblyName |
13 |
typeToDeserialize = Type.GetType(String.Format( "{0}, {1}" , |
14 |
typeName, assemblyName)); |
15 |
16 |
return typeToDeserialize; |
17 |
} |
18 |
} |
19 |
20 |
public static MyRequestObject Deserialize( byte [] b) |
21 |
{ |
22 |
MyRequestObject mro = null ; |
23 |
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); |
24 |
System.IO.MemoryStream ms = new System.IO.MemoryStream(b); |
25 |
26 |
// To prevent errors serializing between version number differences (e.g. Version 1 serializes, and Version 2 deserializes) |
27 |
formatter.Binder = new AllowAllVersionsDeserializationBinder(); |
28 |
29 |
// Allow the exceptions to bubble up |
30 |
// System.ArgumentNullException |
31 |
// System.Runtime.Serialization.SerializationException |
32 |
// System.Security.SecurityException |
33 |
mro = (MyRequestObject)formatter.Deserialize(ms); |
34 |
ms.Close(); |
35 |
return mro; |
36 |
} |
출처:
http://spazzarama.wordpress.com/2009/06/25/binary-deserialize-unable-to-find-assembly/