class object serialization

G

Guest

hi all i want to transfer class object between 2 PDA using library
(inthehand.dll) 32.net,

in windows application BinaryFormatter class is there for serialization of
object. i tried but that class is not supported in .net CF.

My question is, any replacement of that class or any method through which i
can achive serilization, or that cannot be done in .net CF

My class object contains inforation about the drawing.


i want to serialize object and then transfer b/w PDA using bluetooth.



Thanks.
 
G

Guest

Hi,

I've been looking into this. I documentation implies the XmlSerializer
works. I have not tried it yet. I should know soon.

Regards,
Bob
 
P

Paul G. Tobey [eMVP]

Yes, I've used it and it works fine.

Paul T.

Bob Binns said:
Hi,

I've been looking into this. I documentation implies the XmlSerializer
works. I have not tried it yet. I should know soon.

Regards,
Bob
 
P

Paul G. Tobey [eMVP]

Huh? If you use the XML serializer, they sure *are* stored in XML files.

Paul T.
 
N

Neil Cowburn

Binary serialization is not supported under the .NET Compact Framework. Your
best option is to use the XmlSerializer, as suggested by Bob and Paul, and
transfer the XML object graphcs or you can roll your own binary
serialization routines.

--
Neil Cowburn
Principal Partner
OpenNETCF Consulting, LLC.

Managed Code in the Embedded World

http://www.opennetcf.com/
http://www.smartdeviceframework.com/
 
G

Guest

hi,
i have tried XMLserializer in window application, i m using code below to
test on window application befroe porting to
PDA,here is sample code of server
TcpClient client = null;
TcpListener tcpl = new TcpListener(3500);
tcpl.Start();
client = tcpl.AcceptTcpClient();
NetworkStream str = client.GetStream();
try {
TestClass obj = new TestClass();
obj.Name = "Tasleem";
obj.FName = "Arif";

XmlSerializer serial = new XmlSerializer(typeof(TestClass));
serial.Serialize(str,obj);
str.Flush();
MessageBox.Show("Data Written n wait for Read");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
tcpl.Stop();
//here is client side code
TcpClient tcpc = new TcpClient();
tcpc.Connect("127.0.0.1", 3500);
NetworkStream str = tcpc.GetStream();
try {
TestClass obj=null;
XmlSerializer serial = new XmlSerializer(typeof(TestClass));
MessageBox.Show("Read Data");
if (str.DataAvailable)
{
obj = (TestClass)serial.Deserialize(str);
MessageBox.Show(obj.Name);
}
else
MessageBox.Show("No Data Available");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

i m using simple class to test the serialization,
[Serializable()]
public class TestClass
{
private string _Name;
private string _Fname;
public string FName
{ get { return _Fname; } set { _Fname = value; } }
public string Name
{ get { return _Name; } set { _Name = value; } }
}
server side function send successfully and client side function waits and
then it hangs there not able
to desrialize tell me what i m missing?
 
G

Guest

hi,
i have tried XMLserializer in window application, i m using code below to
test on window application befroe porting to
PDA,here is sample code of server
TcpClient client = null;
TcpListener tcpl = new TcpListener(3500);
tcpl.Start();
client = tcpl.AcceptTcpClient();
NetworkStream str = client.GetStream();
try {
TestClass obj = new TestClass();
obj.Name = "Tasleem";
obj.FName = "Arif";

XmlSerializer serial = new XmlSerializer(typeof(TestClass));
serial.Serialize(str,obj);
str.Flush();
MessageBox.Show("Data Written n wait for Read");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
tcpl.Stop();
//here is client side code
TcpClient tcpc = new TcpClient();
tcpc.Connect("127.0.0.1", 3500);
NetworkStream str = tcpc.GetStream();
try {
TestClass obj=null;
XmlSerializer serial = new XmlSerializer(typeof(TestClass));
MessageBox.Show("Read Data");
if (str.DataAvailable)
{
obj = (TestClass)serial.Deserialize(str);
MessageBox.Show(obj.Name);
}
else
MessageBox.Show("No Data Available");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

i m using simple class to test the serialization,
[Serializable()]
public class TestClass
{
private string _Name;
private string _Fname;
public string FName
{ get { return _Fname; } set { _Fname = value; } }
public string Name
{ get { return _Name; } set { _Name = value; } }
}
server side function send successfully and client side function waits and
then it hangs there not able
to desrialize tell me what i m missing?
 
G

Guest

hi,
i have tried XMLserializer in window application, i m using code below to
test on window application befroe porting to
PDA,here is sample code of server
TcpClient client = null;
TcpListener tcpl = new TcpListener(3500);
tcpl.Start();
client = tcpl.AcceptTcpClient();
NetworkStream str = client.GetStream();
try {
TestClass obj = new TestClass();
obj.Name = "Tasleem";
obj.FName = "Arif";

XmlSerializer serial = new XmlSerializer(typeof(TestClass));
serial.Serialize(str,obj);
str.Flush();
MessageBox.Show("Data Written n wait for Read");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
tcpl.Stop();
//here is client side code
TcpClient tcpc = new TcpClient();
tcpc.Connect("127.0.0.1", 3500);
NetworkStream str = tcpc.GetStream();
try {
TestClass obj=null;
XmlSerializer serial = new XmlSerializer(typeof(TestClass));
MessageBox.Show("Read Data");
if (str.DataAvailable)
{
obj = (TestClass)serial.Deserialize(str);
MessageBox.Show(obj.Name);
}
else
MessageBox.Show("No Data Available");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

i m using simple class to test the serialization,
[Serializable()]
public class TestClass
{
private string _Name;
private string _Fname;
public string FName
{ get { return _Fname; } set { _Fname = value; } }
public string Name
{ get { return _Name; } set { _Name = value; } }
}
server side function send successfully and client side function waits and
then it hangs there not able
to desrialize tell me what i m missing?
 
P

Paul G. Tobey [eMVP]

Try just streaming the data to a local file, rather than putting network
stuff in the equation. When you stream the object data to a file, I'm sure
that you'll see that it works just fine. You should be able to copy that
file to the other machine and verify that the object can be read back from
the file, also. I don't see any obvious errors in your code, but I've never
tried to extract serialized objects directly out of a socket...

Paul T.

tasleem said:
hi,
i have tried XMLserializer in window application, i m using code below to
test on window application befroe porting to
PDA,here is sample code of server
TcpClient client = null;
TcpListener tcpl = new TcpListener(3500);
tcpl.Start();
client = tcpl.AcceptTcpClient();
NetworkStream str = client.GetStream();
try {
TestClass obj = new TestClass();
obj.Name = "Tasleem";
obj.FName = "Arif";

XmlSerializer serial = new
XmlSerializer(typeof(TestClass));
serial.Serialize(str,obj);
str.Flush();
MessageBox.Show("Data Written n wait for Read");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
tcpl.Stop();
//here is client side code
TcpClient tcpc = new TcpClient();
tcpc.Connect("127.0.0.1", 3500);
NetworkStream str = tcpc.GetStream();
try {
TestClass obj=null;
XmlSerializer serial = new
XmlSerializer(typeof(TestClass));
MessageBox.Show("Read Data");
if (str.DataAvailable)
{
obj = (TestClass)serial.Deserialize(str);
MessageBox.Show(obj.Name);
}
else
MessageBox.Show("No Data Available");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

i m using simple class to test the serialization,
[Serializable()]
public class TestClass
{
private string _Name;
private string _Fname;
public string FName
{ get { return _Fname; } set { _Fname = value; } }
public string Name
{ get { return _Name; } set { _Name = value; } }
}
server side function send successfully and client side function waits and
then it hangs there not able
to desrialize tell me what i m missing?




Paul G. Tobey said:
Huh? If you use the XML serializer, they sure *are* stored in XML files.

Paul T.
 
G

Guest

ok, you mean first write the all data in XML local file and then transfer
that local file to network, or read the data from local file and then
transfer that data/object.

Paul G. Tobey said:
Try just streaming the data to a local file, rather than putting network
stuff in the equation. When you stream the object data to a file, I'm sure
that you'll see that it works just fine. You should be able to copy that
file to the other machine and verify that the object can be read back from
the file, also. I don't see any obvious errors in your code, but I've never
tried to extract serialized objects directly out of a socket...

Paul T.

tasleem said:
hi,
i have tried XMLserializer in window application, i m using code below to
test on window application befroe porting to
PDA,here is sample code of server
TcpClient client = null;
TcpListener tcpl = new TcpListener(3500);
tcpl.Start();
client = tcpl.AcceptTcpClient();
NetworkStream str = client.GetStream();
try {
TestClass obj = new TestClass();
obj.Name = "Tasleem";
obj.FName = "Arif";

XmlSerializer serial = new
XmlSerializer(typeof(TestClass));
serial.Serialize(str,obj);
str.Flush();
MessageBox.Show("Data Written n wait for Read");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
tcpl.Stop();
//here is client side code
TcpClient tcpc = new TcpClient();
tcpc.Connect("127.0.0.1", 3500);
NetworkStream str = tcpc.GetStream();
try {
TestClass obj=null;
XmlSerializer serial = new
XmlSerializer(typeof(TestClass));
MessageBox.Show("Read Data");
if (str.DataAvailable)
{
obj = (TestClass)serial.Deserialize(str);
MessageBox.Show(obj.Name);
}
else
MessageBox.Show("No Data Available");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

i m using simple class to test the serialization,
[Serializable()]
public class TestClass
{
private string _Name;
private string _Fname;
public string FName
{ get { return _Fname; } set { _Fname = value; } }
public string Name
{ get { return _Name; } set { _Name = value; } }
}
server side function send successfully and client side function waits and
then it hangs there not able
to desrialize tell me what i m missing?




Paul G. Tobey said:
Huh? If you use the XML serializer, they sure *are* stored in XML files.

Paul T.

objects are not stored in XML files,these are binary objects.

:

Yes, I've used it and it works fine.

Paul T.

Hi,

I've been looking into this. I documentation implies the
XmlSerializer
works. I have not tried it yet. I should know soon.

Regards,
Bob

--
Regards,
Bob Binns
http://www.binnsware.com



:

hi all i want to transfer class object between 2 PDA using library
(inthehand.dll) 32.net,

in windows application BinaryFormatter class is there for
serialization
of
object. i tried but that class is not supported in .net CF.

My question is, any replacement of that class or any method through
which
i
can achive serilization, or that cannot be done in .net CF

My class object contains inforation about the drawing.


i want to serialize object and then transfer b/w PDA using
bluetooth.



Thanks.
 
P

Paul G. Tobey [eMVP]

This is just an experiment. Write the data to a file. Copy the file to the
other device. Read the file. It works or not?

Paul T.

tasleem said:
ok, you mean first write the all data in XML local file and then transfer
that local file to network, or read the data from local file and then
transfer that data/object.

Paul G. Tobey said:
Try just streaming the data to a local file, rather than putting network
stuff in the equation. When you stream the object data to a file, I'm
sure
that you'll see that it works just fine. You should be able to copy that
file to the other machine and verify that the object can be read back
from
the file, also. I don't see any obvious errors in your code, but I've
never
tried to extract serialized objects directly out of a socket...

Paul T.

tasleem said:
hi,
i have tried XMLserializer in window application, i m using code below
to
test on window application befroe porting to
PDA,here is sample code of server
TcpClient client = null;
TcpListener tcpl = new TcpListener(3500);
tcpl.Start();
client = tcpl.AcceptTcpClient();
NetworkStream str = client.GetStream();
try {
TestClass obj = new TestClass();
obj.Name = "Tasleem";
obj.FName = "Arif";

XmlSerializer serial = new
XmlSerializer(typeof(TestClass));
serial.Serialize(str,obj);
str.Flush();
MessageBox.Show("Data Written n wait for Read");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
tcpl.Stop();
//here is client side code
TcpClient tcpc = new TcpClient();
tcpc.Connect("127.0.0.1", 3500);
NetworkStream str = tcpc.GetStream();
try {
TestClass obj=null;
XmlSerializer serial = new
XmlSerializer(typeof(TestClass));
MessageBox.Show("Read Data");
if (str.DataAvailable)
{
obj = (TestClass)serial.Deserialize(str);
MessageBox.Show(obj.Name);
}
else
MessageBox.Show("No Data Available");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

i m using simple class to test the serialization,
[Serializable()]
public class TestClass
{
private string _Name;
private string _Fname;
public string FName
{ get { return _Fname; } set { _Fname =
e; } }
public string Name
{ get { return _Name; } set { _Name = value; } }
}
server side function send successfully and client side function waits
and
then it hangs there not able
to desrialize tell me what i m missing?




:

Huh? If you use the XML serializer, they sure *are* stored in XML
files.

Paul T.

objects are not stored in XML files,these are binary objects.

:

Yes, I've used it and it works fine.

Paul T.

Hi,

I've been looking into this. I documentation implies the
XmlSerializer
works. I have not tried it yet. I should know soon.

Regards,
Bob

--
Regards,
Bob Binns
http://www.binnsware.com



:

hi all i want to transfer class object between 2 PDA using
library
(inthehand.dll) 32.net,

in windows application BinaryFormatter class is there for
serialization
of
object. i tried but that class is not supported in .net CF.

My question is, any replacement of that class or any method
through
which
i
can achive serilization, or that cannot be done in .net CF

My class object contains inforation about the drawing.


i want to serialize object and then transfer b/w PDA using
bluetooth.



Thanks.
 
G

Guest

Try http://gotcf.net - BinaryFormatter compatible with the one found on full
..net framework. The object model is the same as in
System.Runtime.Serialization so you can leverage your current desktop skills
when creating mobile application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top