473,387 Members | 1,578 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,387 software developers and data experts.

Branding of serialized class to disk issue

I created two classes called "site" and "Sites" which use 'BinaryFormatter'
to load and save class information to a disk file. In my test application
all works fine but when implementing into another application the code fails
with a message indicating there is a missing assembly. The missing assembly
is the project which serialized the class information to disk e.g.

Test1a, created binary files
DDEP attempted to read them but error points to "Test1a"
My solution was to recreate the data file in the DDEP project which then
marks the data for DDEP and "Test1a" gets the exception "can not find
assembly..."
MY QUESTION:
With the supplied code in mind is there a work-around which would allow the
binary disk file to be accessed by any .NET application, or do I need a
different solution then my current one? Please note I would like to stay
binary to keep
the "average" user out of the files content.

Thanks for taking the time to read this message and provide feedback,
Kevin
ke***************@state.or.us
..NET version 1.1, 2003

Code sniplet
----------------------------------------------------------------
Imports System
Imports System.Configuration
Imports System.IO
Imports System.Data
Imports Dart.PowerTCP
Imports System.Runtime.Serialization.Formatters.Binary
Imports DOR.Utils.Encryption
Imports System.ComponentModel

<Serializable()> Public Class Site
....
End Class

Public Class Sites
Inherits CollectionBase
....
Public Function LoadSitesFromDataFile() As Boolean
Dim BinF As New BinaryFormatter
Dim obj As Object
Dim oSite As Site

If System.IO.File.Exists(DataFile) Then
Try
Dim FS As New System.IO.FileStream(DataFile,
IO.FileMode.OpenOrCreate)
Dim ds As Encryption64 = New Encryption64
Do
obj = BinF.Deserialize(FS)
If obj.GetType Is GetType(Site) Then
oSite = CType(obj, Site)
If oSite.Password.Length > 0 Then
oSite.Password =
ds.DecryptFromBase64String(oSite.Password, Me.UnLockString)
End If
Me.Add(oSite)
End If
Loop While FS.Position < FS.Length - 1
FS.Close()
ds = Nothing
Return True
Catch ioe As System.IO.IOException
Me.m_LastError = TheCaller & Environment.NewLine & ioe.Message
Return False
Catch ex As Exception
Me.m_LastError = TheCaller & Environment.NewLine & ex.Message
Return False
End Try
Else
Return False
End If
End Function
Public Function SaveSitesToDataFile() As Boolean
Const TheCaller As String = "Sites.SaveSitesToDataFile"
If Me.Count = 0 Then
' TODO
Return False
End If
Dim BinF As New BinaryFormatter
Try
Dim FS As New System.IO.FileStream(DataFile, IO.FileMode.Create)
Dim ds As Encryption64 = New Encryption64
Dim oSite As Site

For Each oSite In Me
If oSite.Password.Length > 0 Then
oSite.Password = ds.EncryptToBase64String(oSite.Password,
UnLockString)
End If
BinF.Serialize(FS, oSite)
Next
FS.Close()
ds = Nothing
Catch ioe As System.IO.IOException
' TODO
Return False
Catch ex As Exception
Return False
End Try
End Function
End Class

Jul 21 '05 #1
2 1369
I think if you compile the two classes into a ClassLibrary .dll, then
you should be able to use the code in different projects and also read
in serialized objects regardless of which app serialized them.

Jul 21 '05 #2
Chris,

That makes perfect sense, will have to try it out and report back
(tomorrow).

Thanks!
Kevin

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I think if you compile the two classes into a ClassLibrary .dll, then
you should be able to use the code in different projects and also read
in serialized objects regardless of which app serialized them.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: José Joye | last post by:
I have used the wizard of VisualStudio to generate a DataSet (typed dataSet). I need to have the structure serialized in XML in a nested way and not in a table representation e.g: I have 3...
2
by: andrew lowe | last post by:
Hi, Please bear with me on this problem, first I'll give you some background: I have an object that contains a DateTime field which i pass to a webservice public class Foo { public DateTime...
4
by: Daniel Reber | last post by:
I have an exe that serializes one of it's classes to disk. I also have the exact same .cs file that contains the class that was serialized, in a Windows service application. I am trying to load...
4
by: Bill | last post by:
I have a DataSet that is serialized to a local disk. One of the testers recently experienced a problem where data was saved and the Tablet PC she was testing later went offline. When she restarted...
3
by: kevininstructor | last post by:
I created two classes called "site" and "Sites" which use 'BinaryFormatter' to load and save class information to a disk file. In my test application all works fine but when implementing into...
5
by: EqDev | last post by:
I have a class that is a control derived from UserControl. I want to use serialization and deserialization with this calss but I get an exception "Cannot serialize member...
3
by: CindyRob | last post by:
I am using .NET framework 1.1 SP1, .NET framework SDK 1.1 SP1, with hotfix 82202, Visual studio .NET 2003 with hotfix 823639. I have generated a proxy class using wsdl.exe from a schema that has an...
1
by: Knoxy | last post by:
Hi folks, Just a quick post to see if anyone had any thoughts on branding a website for completely different website designs. I have a site at the minute that gets installed with another...
0
by: bharathreddy | last post by:
Before going to that i want to say few thing on serialization : Serialization is the process of converting an object into a form that can be readily transported. For example, you can serialize an...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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 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.