all groups > dotnet remoting > june 2004 >
You're in the

dotnet remoting

group:

Problem with .NET remoting and Hashtable


Re: Problem with .NET remoting and Hashtable Allen Anderson
6/7/2004 12:59:21 PM
dotnet remoting:
just looking at your code there I don't see anything that would change
whether it was a hashtable or arraylist. Your not actually sending
the hashtable anywhere so really the hashtable should nothing to do
with remoting. Could you be more speciofic and post some code where
it fails?

Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com

[quoted text, click to view]
Problem with .NET remoting and Hashtable Tommi
6/7/2004 2:24:16 PM

I have a serializable class called MyFile in Server-side. Like this:

<Serializable()> _
Public Class MyFile

Public Binaari() as Byte

Public Function Upload(ByVal fileName As String) As Boolean
Dim file As System.IO.FileStream

file = New IO.FileStream(fileName, IO.FileMode.Open)
Dim byteArray(CType(file.Length - 1, Integer)) As Byte
file.Read(byteArray, 0, CType(file.Length, Integer))

Binaari = byteArray

file.Close()
file = Nothing

End Function

End Class

Client uses .NET remoting (HTTP; Binary as formatter) to use
Server-side classes. I create new instance from MyFile class in Client
and I call Upload method to upload file to byte array.

Public Class ClientTest

Private hTable As New Hashtable

Private Sub Test()
Dim olio As New MyFile
olio.Upload("C:\Test.txt")
hTable.Add("Key", olio)
End Sub

End Class

If I introduce hTable variable after I use Upload method everything
works ok, but if I introduce hTable variable before I use Upload
method I got an error: "Object Reference not set to an instance of an
object". Why? If I change Hashtable to arraylist it also works fine.

I Think .NET remoting call causes Hashtable variable to lose it's
handle....

Re: Problem with .NET remoting and Hashtable Tommi
6/8/2004 5:57:22 AM
On Mon, 07 Jun 2004 12:59:21 -0600, Allen Anderson
[quoted text, click to view]

Ok, here is couple of examples at client-side.

Working solution:

Public Class ClientTest

Private Sub Test()

Dim olio As New MyFile
olio.Upload("C:\Test.txt") ' .NET Remoting call

Dim hTable As New Hashtable
hTable.Add("Key", olio)
End Sub

End Class

Non-working solution:

Public Class ClientTest

Private hTable As New Hashtable

Private Sub Test()
Dim olio As New MyFile
olio.Upload("C:\Test.txt") ' .NET Remoting call
hTable.Add("Key", olio) ' This add method causes error
End Sub

End Class

When I introduce hTable variable before I use any .NET remoting call I
got error "Object Reference not set to an instance of an object" but
if I introduce hTable variable after I use .NET remoting call
everything works ok.

HashTable shouldn't have nothing to do with .NET remoting as you said
but .NET remoting call causes hTable variable to lose it handle or
something.

Re: Problem with .NET remoting and Hashtable Tommi
6/8/2004 6:21:40 AM
On Mon, 07 Jun 2004 12:59:21 -0600, Allen Anderson
[quoted text, click to view]

I Messed up my examples at my previous post but here they are again:

Working solution:

Public Class ClientTest

Private Sub Test()

Dim olio As New MyFile
olio.Upload("C:\Test.txt")
' Insert .NET Remoting call to this line

Dim hTable As New Hashtable
hTable.Add("Key", olio)
End Sub

End Class

Non-working solution:

Public Class ClientTest

Private hTable As New Hashtable

Private Sub Test()
Dim olio As New MyFile
olio.Upload("C:\Test.txt")
' Insert .NET Remoting call to this line

hTable.Add("Key", olio) ' This add method causes error
End Sub

End Class

When I introduce hTable variable before I use any .NET remoting call I
got error "Object Reference not set to an instance of an object" but
if I introduce hTable variable after I use .NET remoting call
everything works ok.

HashTable shouldn't have nothing to do with .NET remoting as you said
but .NET remoting call causes hTable variable to lose it handle or
something.

AddThis Social Bookmark Button