Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / September 2007

Tip: Looking for answers? Try searching our database.

How to return an object through a webmethod

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fré - 27 Sep 2007 20:52 GMT
Hi,

I'm having some trouble creating my webservice.

I can easaly return simple datatypes like strings, integers,..., but
returning something like an object doesn't seem to work.

I tried putting <Serializable()> _ in the class, but no difference.

It gives the following error:

System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: clsUpdate cannot be
serialized because it does not have a parameterless constructor.

Could anyone please help me out with this ? I'm using VS2005, language VB.net

Thx,

Frederick
John Saunders [MVP] - 27 Sep 2007 21:56 GMT
> Hi,
>
[quoted text clipped - 10 lines]
> document. ---> System.InvalidOperationException: clsUpdate cannot be
> serialized because it does not have a parameterless constructor.

The exception gives you the answer. The class doesn't have a parameterless
constructor.

> Could anyone please help me out with this ? I'm using VS2005, language
> VB.net

Public Sub New()
End Sub

Signature

--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

Fré - 28 Sep 2007 08:06 GMT
You are right, I've read the error, but somehow i didn't hear the bell ringing.

I adapted my code, but then got another error, telling me I should use
XmlInclude.

I changed the line "<WebMethod()> _" to "<WebMethod(),
XmlInclude(GetType(clsMyClass))> _", and everything works just fine now.

Thanks a lot,

Frederick

> > Hi,
> >
[quoted text clipped - 19 lines]
> Public Sub New()
> End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.