BinaryFormatter.Deserialize and Smart Clients

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top