'
--------------------------------------------------------------------------
And here it is:
' VB.NET code to save the ArrayList object to file
' it could have been in any other dot NET language.
'
--------------------------------------------------------------------------
Private xlist As New ArrayList()
<Serializable()> Structure Human
Dim firstname As String
Dim lastname As String
End Structure
For i = 0 to <any Number>
Dim p As Human
p.firstname = "Obinna"
p.lastname = "Chikwendu"
xlist.Add(p)
Next
Dim fName As String = "C:\test.bin"
Dim fs As FileStream
Dim bf As New BinaryFormatter()
fs = File.Create(fName)
fs.Seek(0, SeekOrigin.End)
bf.Serialize(fs, xlist)
fs.Close()
/************************************************** **************
C# code to retrieve the value stored in the file
Note: it works if both are compiled in the same assembly
but I intend to load the ArrayList from a different assembly
************************************************** **************/
String fName = "C:\test.bin";
FileStream fs;
BinaryFormatter bf = new BinaryFormatter();
try{
fs = File.OpenRead(fName);
xlist = CType(bf.Deserialize(fs), ArrayList);
// retrieving the data from file ...
Human p;
for (i = 0; i < xlist.Count - 1; i++){
p = xlist.Item(i);
str = p.firstname & " " & p.lastname;
}
}
catch (Exception exp){
MessageBox.Show(exp.Message);
}
finally{
fs.Close();
}
/*******************************
When run the message box displays:
"File or assembly name <Project name>, or one of its dependencies,
was not found."
What's with the Assembly Stuff?
***********************************/
Nicholas Paldino [.NET/C# MVP] wrote:
Unfortunately, without theat assembly stuff, it will be difficult to
determine what the problem is.
Can't you reproduce it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Obinna" <ob**************@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com... Well I wrote this code that saved a Serialized ArrayList to disk in
VB.NET and tried to read it in with another one in C#. Got some funny
exception about my Assembly (can't rember exactly), what's with the
assembly stuff.