473,382 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Deserialize causes exception "Unable to find assembly"

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
1 8082
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stephen Ferg | last post by:
I use the newsgroup mainly via my Web browser and Google. Over the last few days, when I click on a link to a thread, I've been frequently getting the message "Unable to find thread." Does...
2
by: Andrew | last post by:
VS.net Win 2k3 I'm getting the following error when attempting to debug. I'm not debugging remotely, just a local project. "Unable to start debugging. Cannot find port. Check the remote...
1
by: sathyp | last post by:
Public Function SetPrinterDefaultsW(ByVal sPrinterName As String, _ ByVal nPaperSize As Long, ByVal nOrientation As Long) As Boolean Dim Prn As Printer Dim hPrinter As Long Dim pd As...
2
by: Nils Magnus Englund | last post by:
Hello, In the root of a web site (C:\Inetpub\wwwroot), I have a .NET 1.1 application. I've just added a .NET 2.0 application to another directory under the web site root...
4
by: JackBlack | last post by:
Hi, all! Need a little help tracking down a runtime error problem. I'm getting this error: "Unable to cast object of type 'myStruct' to type 'myStruct'... but the two types are identical! I...
3
by: GMiller | last post by:
I have deployed a .NET 2 application on a customer's system. I'm trying to use the .NET 1.1 configuration tool to load the assembly but I always get an 'unable to load assembly" message. What is...
1
by: Martin Plechsmid | last post by:
Hello, (After investigating my real problem) I've got a C# web service containing a single method: public MyBDO Test() { return null; }
5
by: bogorman | last post by:
Am a newcomer to Visual Studio 2005 but have managed to develop a simple application in VB using it. I want to deploy it. Have tried using ClickOnce which generates the webpage ok. I can install the...
1
by: KevinMurphyRJLG | last post by:
I'm trying to migrate a large solution (20 or so projects) from .NET 1.1 to .NET 2.0. I've taken care of all the compile errors, but now I'm getting an exception shortly after I start up the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.