By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Deserialize causes exception "Unable to find assembly"

P: n/a
Hi

Trying to copy a complex data structure with this code
public object Clone()
{
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, this);
ms.Position = 0;
object obj = bf.Deserialize(ms);
ms.Close();
return obj;

}
I have a text exe that works where the EXE and dll assemblies are all in
same directory. When I move the code to production I get the above exception.
The only thing I can see is difference is that the product install of files
is different

C:/Company/EXEDir
C:/Company/AssembleyDir
The EXE is executing in one directory and all the assemblies that are called
are in another dir. I scanned the web but didn't find much but there was a
reference to the fact that all the Deserializd Classes need to be in the same
dir which they are. I also added code to set dir to where the assemblies are

Directory.SetCurrentDirectory(Path.GetDirectoryNam e(Assembly.GetExecutingAssembly().Location));
Environment.CurrentDirectory =
Path.GetDirectoryName(Assembly.GetExecutingAssembl y().Location);
Not sure what else to look at ???

Thanks
Nov 19 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"sippyuconn" <si********@newsgroup.nospamwrote in message
news:73**********************************@microsof t.com...
Hi

Trying to copy a complex data structure with this code
public object Clone()
{
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, this);
ms.Position = 0;
object obj = bf.Deserialize(ms);
ms.Close();
return obj;

}
I have a text exe that works where the EXE and dll assemblies are all in
same directory. When I move the code to production I get the above
exception.
The only thing I can see is difference is that the product install of
files
is different

C:/Company/EXEDir
C:/Company/AssembleyDir
The EXE is executing in one directory and all the assemblies that are
called
are in another dir. I scanned the web but didn't find much but there was a
reference to the fact that all the Deserializd Classes need to be in the
same
dir which they are. I also added code to set dir to where the assemblies
are

Directory.SetCurrentDirectory(Path.GetDirectoryNam e(Assembly.GetExecutingAssembly().Location));
Environment.CurrentDirectory =
Path.GetDirectoryName(Assembly.GetExecutingAssembl y().Location);
Not sure what else to look at ???

Thanks
Here is an MS link, but basically, I think you will find it easier just to
move the dlls to the same folder as the executable.

http://msdn.microsoft.com/en-us/library/yx7xezcf.aspx

Nov 19 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.