specifying where to look for assembly when executing BinaryFormatter.Deserialize

R

Ryan.Mohammed

I have a problem where the code that serializes and deserializes an
object is actually not the start application but loaded by reflection
and located in a subdirectory of the start application.

Example

\
Start.exe
Platforms\Sub\Running.dll

Running.dll serializes an object that is defined in Running.dll using
BinaryFormatter. As an experiment, I deserialize the binary in the same
Running.dll expecting it to recreate my object however it seems to look
in the root directory of the application (where Start.exe exists) and
hence fails to find the Running assembly (an exception is thrown).

As an experiment, if I copy Running.dll to the root directory it
actually deserializes ok to an object but then there are other problems
since I am still in executing in Running.dll and can't cast to an
object that basically has a different type since the deserializer
identified it from another copy of the dll.

Hope this is not too confusing , any help would be appreciated. I think
that all I need to solve is somehow to get the deserilizer to look at
the executing assembly and not try to find another.
 

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