BinaryFormatter.Deserialize and Smart Clients

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a framework of an application that consumes web methods with Dime
attachments. Upon receipt of a reponse I have the following code to unpack
the attachments:

Dim f As New BinaryFormatter
Dim retObjects(ws.ResponseSoapContext.Attachments.Count - 1) As
Object
For i As Int32 = 0 To ws.ResponseSoapContext.Attachments.Count - 1
retObjects(i) =
f.Deserialize(ws.ResponseSoapContext.Attachments(i).Stream)
Next
Return retObjects

All works fine when run as a normal client but when it is wrapped into a
smart client and on attempted deserialization the assembly contained within
the attachment can not be found throwing an exception :

[mscorlib]System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo::GetAssembly()

Cannot find the assembly BusinessLayer.Data, Version=1.0.1994.24963,
Culture=neutral, PublicKeyToken=null.

Listing the download cache using gacutil /ldl includes:

BusinessLayer.Data, Version=1.0.1994.24963, Culture=neutral,
PublicKeyToken=null, Custom=null

So why is it not finding it??, fusion logs only refer to looking for the
assembly in the smart client stubb applications executing directory.

thanks
Alan
 
Found the problem. The BinaryFormatter Deserialize method call by default
only looks for the bind type in the executing folder. As I needed it to call
the assembly from a remote server I needed to create a SerializationBinder
class and then implement the BindToType function. Once done set the Binder
property of the BinaryFormatter as it works.
 
Back
Top