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

Serializable class problem

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 to mine? 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

..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
Nov 21 '05 #1
1 1177
Since there are no replies I am moving this message to "DotNet General"
Forumn. If a moderator can remove this message here that would be great.
Nov 21 '05 #2

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

Similar topics

8
by: xmail123 | last post by:
Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web methods. ...
3
by: Barguast | last post by:
Has anyone got any idea what might be causing this message to be shown? It occurs whenever I try to copy / cut my custom control from the Form Designer: ...
0
by: Joshua Belden | last post by:
I have a class that is marked as Serializable that implements INotifyPropertyChanged. private event PropertyChangedEventHandler _PropertyChanged; public event PropertyChangedEventHandler...
2
by: John | last post by:
Hi What is a Serializable class compared to a normal class? Thanks Regards
9
by: Developer | last post by:
Hi, How can one tell wsdl.exe/VS.NET web service proxy generatioon to to put on imported classes? For example, i fin your web service you use a class: class Data { }
2
by: Frank Uray | last post by:
Hi again I have a little problem with "serializable" a control ... I am creating AppDomain, Assembly and Instance. All works fine. My "base" class for the instance inherit from: -...
1
by: MrFile | last post by:
My company has developed a backend component which needs to be carried around in session state, therefore it must be marked at the class level. The problem I have with this is that now any...
3
by: Techno_Dex | last post by:
I'm wanting to create a Wrapper (or Extender depending on how you look at it) for a Serializable object that I then want to send over a webservice. Basically I want to create a Serializable Object,...
4
by: dani k | last post by:
How do I write my own serialization of a class that has non-serializable data members? this problem arose when I tried to serialize RSAParameters, for which the private stuff is not serializable
0
mmfranke
by: mmfranke | last post by:
Hello. Hi. I'm writing a logging service that uses .NET remoting. The idea is that the service publishes an EventProcessor object that clients can access via .NET Remoting, passing it...
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
marktang
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.