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

Storing a non serializable object

Hi,

Disappointingly, I think I already know the answer to this question.

I have a C# class which I'm effectively using as a storage area while
I carry out a sequence of Web Method calls on a third party web
service. The class stores the types returned from each call for the
subsequent method call as they are designed to be done sequentially.

I decided as part of my error handling to try and store the storage
object on a failure; this would be in addition to the event log I was
creating along the way. I made the storage object serializable and put
the code in to convert it to a byte[], unfortunately the types
supplied by third party aren't serializable so it won't work.

Can anyone tell me a way to store this object in my MSSQL database for
inspection on error? There are a not insignificant number of values
stored in it, so it'd be nice to do it as a lump.

Thanks in advance

Owen

May 1 '07 #1
4 3614
If the types are returned from a webservice they *must* be serializable,
otherwise how would they be sent over the wire as XML in a SOAP Envelope?
Must be something else going on here.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"owen79" wrote:
Hi,

Disappointingly, I think I already know the answer to this question.

I have a C# class which I'm effectively using as a storage area while
I carry out a sequence of Web Method calls on a third party web
service. The class stores the types returned from each call for the
subsequent method call as they are designed to be done sequentially.

I decided as part of my error handling to try and store the storage
object on a failure; this would be in addition to the event log I was
creating along the way. I made the storage object serializable and put
the code in to convert it to a byte[], unfortunately the types
supplied by third party aren't serializable so it won't work.

Can anyone tell me a way to store this object in my MSSQL database for
inspection on error? There are a not insignificant number of values
stored in it, so it'd be nice to do it as a lump.

Thanks in advance

Owen

May 2 '07 #2
I'm fairly new to Webservices, so can I tell you the situation and see
if that helps any.

I added a Web Reference using the url for the .asmx that has all of
their method. The reference has hundreds of types like
LoginRequestType which is populated with username and password. The
loginRequestType is passed to a LoginResponseType as a constructor and
returns a LoginResponseType.

My storage class has a LoginResponseType property which I store the
response in, when I try to serialize my class, I get an error to the
effect of LoginResponseType could not be serialized.

So that was where I got that the third party types weren't
serializable. Have I totally got the wrong end of the stick.

Owen

May 2 '07 #3
"owen79" <ow*********@googlemail.comwrote in message
news:11*********************@l77g2000hsb.googlegro ups.com...
Disappointingly, I think I already know the answer to this question.

I have a C# class which I'm effectively using as a storage area while
I carry out a sequence of Web Method calls on a third party web
service. The class stores the types returned from each call for the
subsequent method call as they are designed to be done sequentially.

I decided as part of my error handling to try and store the storage
object on a failure; this would be in addition to the event log I was
creating along the way. I made the storage object serializable and put
the code in to convert it to a byte[], unfortunately the types
supplied by third party aren't serializable so it won't work.
Instead of using a BinaryFormatter, use the XmlSerializer. This one can
serialize a class even if it is not marked as [Serializable], with the
restriction that it will only save the public fields and read-write
properties, and that it requires a default constructor. But the objects you
are using should be adequate for serializing in this way because otherwise
they wouldn't transfer adequately over the web service, so the XmlSerializer
should solve your problem.

May 2 '07 #4
Your Reference.cs (Reference.vb) class that was created via the Add Web
Reference dialog should contain the proxy versions of the classes that you
want to use. Look in there. These will be eminently serializable, since they
accurately represent what is actually going back over the wire as XML.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"owen79" wrote:
I'm fairly new to Webservices, so can I tell you the situation and see
if that helps any.

I added a Web Reference using the url for the .asmx that has all of
their method. The reference has hundreds of types like
LoginRequestType which is populated with username and password. The
loginRequestType is passed to a LoginResponseType as a constructor and
returns a LoginResponseType.

My storage class has a LoginResponseType property which I store the
response in, when I try to serialize my class, I get an error to the
effect of LoginResponseType could not be serialized.

So that was where I got that the third party types weren't
serializable. Have I totally got the wrong end of the stick.

Owen

May 2 '07 #5

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

Similar topics

2
by: jakk | last post by:
Below is the exception that Iam getting. It says that the DataView that Iam storing in the session is not Serializable. BUt works fine if I store in the inproc session and fails if I switch to...
10
by: Mark Rae | last post by:
Hi, This relates to the previous thread "Disappearing Sessions", but is a bit more generic so I thought I'd start a new thread. This one relates to the storing of objects in Session once only to...
3
by: Nayan Mansinha | last post by:
Hi All How can I store an array of objects in my C# Application.Settings? I have CMyObject class for which an array is created: CMyObject arr = new CMyObject; arr = new CMyObject();...
3
by: Mark | last post by:
I'm consuming a webservice that makes a simple object available. The object class is marked in the web service as . I have a web application that consumes and uses this web service's class. When...
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,...
2
by: Paul Hadfield | last post by:
Hi, I'm not having a lot of luck googling for this one, I want to be able to store a custom class in the user settings (DotNet2.0, win app). I don't wish to create public get / set properities...
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
4
by: =?Utf-8?B?YmFzdWxhc3o=?= | last post by:
Hi; I want to store a datatable (or an arraylist) as a session variable but when I try; Session = al_RecNo; I get an error that; "Cannot implicitly convert type...
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.