Hi,
I'm having a deserialization problem with a dll plug-in I'm writing, it
serializes just fine but I'm getting an exception on the deserialization
process.
A first chance exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
mscorlib.dll
DeserializeTopHat: Unable to find assembly 'Tools, Version=0.2005.22.0,
Culture=neutral, PublicKeyToken=null'.
Any ideas would be greatly appreciated.
Brent
Here is my class that I want to serialize:
[Serializable()]
public class TopHat : ISerializable
{
public string Description;
public decimal BaseTH;
public decimal Crown;
public decimal Flange;
public decimal Webdepth;
public decimal Parameter;
public bool Finished;
public TopHat()
{
Description = String.Empty;
BaseTH = 0.0M;
Crown = 0.0M;
Flange = 0.0M;
Webdepth = 0.0M;
Parameter = 0.0M;
Finished = false;
}
//Deserialization constructor
public TopHat(SerializationInfo info, StreamingContext ctxt)
{
Description = (String)info.GetValue("Description",
typeof(string));
BaseTH = (decimal)info.GetValue("BaseTH", typeof(decimal));
Crown = (decimal)info.GetValue("Crown", typeof(decimal));
Flange = (decimal)info.GetValue("Flange", typeof(decimal));
Webdepth = (decimal)info.GetValue("Webdepth", typeof(decimal));
Parameter = (decimal)info.GetValue("Parameter",
typeof(decimal));
Finished = (bool)info.GetValue("Finished", typeof(bool));
}
//Serialization function
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
info.AddValue("Description", Description);
info.AddValue("BaseTH", BaseTH);
info.AddValue("Crown", Crown);
info.AddValue("Flange", Flange);
info.AddValue("Webdepth", Webdepth);
info.AddValue("Parameter", Parameter);
info.AddValue("Finished", Finished);
}
public override string ToString()
{
return Description;
}
}
Here is where I serailize, first I dump to a temp file and then read that
into a byte[] array so I can store it on a OLEObject in my access database:
string filelocation = Application.UserAppDataPath + "\\blah.tmp";
Stream a = File.Open(filelocation, FileMode.Create);
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Serialize(a, this._tp.Tophat);
System.Byte[] s_shape = new byte[a.Length];
a.Position = 0;
for (long i = 0; i < a.Length; i++)
s_shape[i] = (byte)a.ReadByte();
a.Close();
this.daShapes.Fill(this.dsShapes, "shapes");
System.Data.DataRow newRow = this.dsShapes.Tables["shapes"].NewRow();
newRow["typeid"] = Shapes.TopHat;
newRow["shape"] = s_shape;
this works just fine.
This is what I do when I deserial
TopHat tophat = new TopHat();
string filelocation = Application.UserAppDataPath +
"\\blah.tmp";
Stream stream = File.Open(filelocation, FileMode.Create);
try
{
stream.Write(s_shape, 0, s_shape.Length);
stream.Position = 0;
BinaryFormatter bformatter = new BinaryFormatter();
object o = bformatter.Deserialize(stream);
tophat = (TopHat)o;
}
catch (Exception ex)
{
Debug.WriteLine("DeserializeTopHat: " + ex.Message);
}
finally
{
stream.Close();
} 1 11038
Hi Brent,
the problem is that the code cannot deserialize the types because it
cannot find the assembly that contains the type information which will allow
it to reassemble to objects. You can do two things:
1. Register the assembly in the GAC
2. Make sure the assembly is in a place where the executing code can find it
such as in the executing directory.
Hope that helps
Mark Dawson http://www.markdawson.org
"Brent Starkes" wrote: Hi,
I'm having a deserialization problem with a dll plug-in I'm writing, it serializes just fine but I'm getting an exception on the deserialization process.
A first chance exception of type 'System.Runtime.Serialization.SerializationExcepti on' occurred in mscorlib.dll DeserializeTopHat: Unable to find assembly 'Tools, Version=0.2005.22.0, Culture=neutral, PublicKeyToken=null'.
Any ideas would be greatly appreciated.
Brent
Here is my class that I want to serialize:
[Serializable()] public class TopHat : ISerializable { public string Description; public decimal BaseTH; public decimal Crown; public decimal Flange; public decimal Webdepth; public decimal Parameter; public bool Finished;
public TopHat() { Description = String.Empty; BaseTH = 0.0M; Crown = 0.0M; Flange = 0.0M; Webdepth = 0.0M; Parameter = 0.0M; Finished = false; }
//Deserialization constructor public TopHat(SerializationInfo info, StreamingContext ctxt) { Description = (String)info.GetValue("Description", typeof(string)); BaseTH = (decimal)info.GetValue("BaseTH", typeof(decimal)); Crown = (decimal)info.GetValue("Crown", typeof(decimal)); Flange = (decimal)info.GetValue("Flange", typeof(decimal)); Webdepth = (decimal)info.GetValue("Webdepth", typeof(decimal)); Parameter = (decimal)info.GetValue("Parameter", typeof(decimal)); Finished = (bool)info.GetValue("Finished", typeof(bool)); }
//Serialization function public void GetObjectData(SerializationInfo info, StreamingContext ctxt) { info.AddValue("Description", Description); info.AddValue("BaseTH", BaseTH); info.AddValue("Crown", Crown); info.AddValue("Flange", Flange); info.AddValue("Webdepth", Webdepth); info.AddValue("Parameter", Parameter); info.AddValue("Finished", Finished); }
public override string ToString() { return Description; } }
Here is where I serailize, first I dump to a temp file and then read that into a byte[] array so I can store it on a OLEObject in my access database:
string filelocation = Application.UserAppDataPath + "\\blah.tmp"; Stream a = File.Open(filelocation, FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(a, this._tp.Tophat); System.Byte[] s_shape = new byte[a.Length]; a.Position = 0; for (long i = 0; i < a.Length; i++) s_shape[i] = (byte)a.ReadByte(); a.Close();
this.daShapes.Fill(this.dsShapes, "shapes"); System.Data.DataRow newRow = this.dsShapes.Tables["shapes"].NewRow(); newRow["typeid"] = Shapes.TopHat; newRow["shape"] = s_shape;
this works just fine.
This is what I do when I deserial
TopHat tophat = new TopHat(); string filelocation = Application.UserAppDataPath + "\\blah.tmp"; Stream stream = File.Open(filelocation, FileMode.Create); try { stream.Write(s_shape, 0, s_shape.Length); stream.Position = 0;
BinaryFormatter bformatter = new BinaryFormatter(); object o = bformatter.Deserialize(stream); tophat = (TopHat)o; } catch (Exception ex) { Debug.WriteLine("DeserializeTopHat: " + ex.Message); } finally { stream.Close(); } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: news.microsoft.com |
last post by:
I have created an add-in for VS.NET and when it starts I want the add-in to
read the options from file.
I have created a class (with the attribute set) that contains
the options and implemented...
|
by: Tim Anderson |
last post by:
I have an app that uses the SOAP serializer to serialize and deserialize a
object of a certain class to a file. The class implements ISerializable.
From time to time it is necessary to add or...
|
by: Michael Gorbach |
last post by:
Hi,
My project is set up with 1 main form and 2 sub forms declared inside
it. Inside the main form i have declared a simulation object (class i
wrote), which is passed in as a parameter to...
|
by: Steve |
last post by:
I've been following a couple remoting tutorials on the web, they are all
pretty much the same.
I've got my different applications built(client, server and remote object
(dll))
The client is...
|
by: Really stuck |
last post by:
Hello,
I'm getting the following error now with my aplication, but only when I run it ocally on my machine:
System.Runtime.Serialization.SerializationException: Cannot find member name...
|
by: jakk |
last post by:
Below is the exception that Iam getting. It says that the DataView that
Iam storing in the session is not Serializable. BUt works fine if I
store in the inproc session and fails if I switch to...
|
by: Sharon |
last post by:
Hi,
I'm using the remoting, and I have a remoting object that has a public event
that other processes should register to it.
But when the client process is registering to the remote event, it...
|
by: Robert Altland |
last post by:
I've encountered the following exception when deploying my solution to a load
balanced environment:
Unable to find assembly 'App_WebReferences.wayyy8_t, Version=0.0.0.0,
Culture=neutral,...
|
by: semedao |
last post by:
Hi All,
I had working code that made custom serialization on objects that inherit from queue
in the inherited queue I create my own GetObjectData:
public void GetObjectData(SerializationInfo info,...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |