PC Review


Reply
Thread Tools Rate Thread

Deserializaion - object is null although fields are available throughVS intelisense.

 
 
YZ
Guest
Posts: n/a
 
      26th Jun 2011
Greetings.

I'm trying to build a messanger application.I managed to build peer-to-
peer and now I'm trying to build one with a server.
First I'll give a short summary of how I built the application.
I create an Envelope class with two properties: Message (which is an
abstract class) and Enum named contentType which indicates which type
of message is inside the Envelope object.
Then I created a class named HeartbeatMessage which inherits Message.
I created another class which inherits Message named
ServerUpdateMessage.
I created a Server class which has a TcpListener and a method named
Listen which waits for stream.Once a stream arrives it deserialize
it,while casting to Envelope.Then fire an event (which I created
earlier) who receives this envelope for further processing.

Both client and server has an instance of the Server class.

The procedure is as follows:
When the server form is up it starts the Server.Listen method on a
separate thread so the GUI keeps on responding.
Then the chat form is up sending a heartbeat message to the server.
The Server.Listen method of the server form process the
stream,deserialize it while casting to envelope and the event is
fired.
Then it check the content and see it is heatbeat.If the user is new to
the server it sends an Envelope with ServerUpdateMessage to all users
he knows (in my environment only one).
When the chat form Server.Listen (which also operates on a separate
thread for GUI response) the problem starts.
I work in debug and go line by line.
I can see a stream with data arriving,then I put it in memory stream
in order to deserialize it (all this is part of Server.Listen which
operates fine on the server form.),Then I deserialize it while casting
to Envelope and put the result in an Envelope object.
In Visual Studio I can see the Envelope object with the fields and
values I sent from the server.
Then I try to fire the event with this envelope and receive : "object
reference not set to an instance of an object".
I searched the net and asked my colleagues but didn't manage to find
an answer.
I then put a message box after the deserialization with one of the
properties if the ServerUpdateMessage object inside the deserialized
envelope object and I can see the text in the message box.And then
again the exception occurred when fired the event!!!

I'm very frustrated and will be thankful to any crumb who will lead to
a solution.

Thanks in advance,
YZ.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASPX page jscript rt error: null is null or not an object Cirene Microsoft ASP .NET 2 8th Sep 2010 02:04 PM
Fill null fields from last non-null record - No update query pleas mattsmom Microsoft Access 2 2nd Apr 2008 01:56 PM
Fill null fields from last record non-null in that field CS Microsoft Access 3 4th Jan 2008 08:39 AM
Null Group Fields Not Equal to Null Non-Grouped Fields =?Utf-8?B?Q2hlcnlsIExhbW9uZHM=?= Microsoft Access Queries 3 29th Apr 2005 12:22 AM
Runtime error 'null" is null or not an object Doris Windows XP Internet Explorer 0 15th Jul 2004 03:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:38 PM.