System.InvalidOperationException: The type myobject[] may not be used in this context.

J

Jeremy

I am trying to return a custom object from a web service, and get this very
cryptic message.

System.InvalidOperationException: There was an error generating the
XML document. --->
System.InvalidOperationException: The type myobject[] may not
be used in this context.

What does it mean?

The object I am returning has a couple of fields, plus an array containing
objects. The error message indicates a problem with creating xml for an
object in the array of objects.

Either no one else has problems with this, or no one else is doing this.
Maybe there is a better way. I'm open to suggestions.

Jeremy
 
T

Trebek

Take a look at the XmlIncludeAttribute class (or SoapInclude if SoapRpc --
depending on your needs).

Should fix you up ....

Alex
 
J

Jeremy

Alex, thanks. Can you help me out with the syntax? Based on the c# example
in help, I deduce the following VB, but it gives a syntax error telling me I
need more continuation characters. The squigglies show up under the "<" in
"<xmlinclude(...".
<WebMethod()> _

<xmlinclude(typeof(myMainObject)), xmlinclude(typeof(myEmbeddedObject))> _

Public Function getData(ByVal key1 As String, ByVal key2 As String) As
myMainObject

getData = some stuff.

end function

Jeremy


Trebek said:
Take a look at the XmlIncludeAttribute class (or SoapInclude if SoapRpc --
depending on your needs).

Should fix you up ....

Alex


Jeremy said:
I am trying to return a custom object from a web service, and get this very
cryptic message.

System.InvalidOperationException: There was an error generating the
XML document. --->
System.InvalidOperationException: The type myobject[] may not
be used in this context.

What does it mean?

The object I am returning has a couple of fields, plus an array containing
objects. The error message indicates a problem with creating xml for an
object in the array of objects.

Either no one else has problems with this, or no one else is doing this.
Maybe there is a better way. I'm open to suggestions.

Jeremy
 
T

Trebek

Sorry Jeremy .. never messed with vb or vb.net ... always been a C-based
programmer :( but I though it *should* look something like the following
based on MSDN:

<XmlElement(Type:=GetType(your_first_possible_class)),
XmlElement(Type:=GetType(your_next_possible_class))>


HTH,

Alex

Jeremy said:
Alex, thanks. Can you help me out with the syntax? Based on the c# example
in help, I deduce the following VB, but it gives a syntax error telling me I
need more continuation characters. The squigglies show up under the "<" in
"<xmlinclude(...".
<WebMethod()> _

<xmlinclude(typeof(myMainObject)), xmlinclude(typeof(myEmbeddedObject))> _

Public Function getData(ByVal key1 As String, ByVal key2 As String) As
myMainObject

getData = some stuff.

end function

Jeremy


Trebek said:
Take a look at the XmlIncludeAttribute class (or SoapInclude if SoapRpc --
depending on your needs).

Should fix you up ....

Alex


Jeremy said:
I am trying to return a custom object from a web service, and get this very
cryptic message.

System.InvalidOperationException: There was an error
generating
the
XML document. --->
System.InvalidOperationException: The type myobject[] may not
be used in this context.

What does it mean?

The object I am returning has a couple of fields, plus an array containing
objects. The error message indicates a problem with creating xml for an
object in the array of objects.

Either no one else has problems with this, or no one else is doing this.
Maybe there is a better way. I'm open to suggestions.

Jeremy
 
T

Trebek

Opps ... replace with the appropriate attribute :)

Alex


Trebek said:
Sorry Jeremy .. never messed with vb or vb.net ... always been a C-based
programmer :( but I though it *should* look something like the following
based on MSDN:

<XmlElement(Type:=GetType(your_first_possible_class)),
XmlElement(Type:=GetType(your_next_possible_class))>


HTH,

Alex

Jeremy said:
Alex, thanks. Can you help me out with the syntax? Based on the c# example
in help, I deduce the following VB, but it gives a syntax error telling
me
I
need more continuation characters. The squigglies show up under the "<" in
"<xmlinclude(...".
<WebMethod()> _

<xmlinclude(typeof(myMainObject)), xmlinclude(typeof(myEmbeddedObject))> _

Public Function getData(ByVal key1 As String, ByVal key2 As String) As
myMainObject

getData = some stuff.

end function

Jeremy


Trebek said:
Take a look at the XmlIncludeAttribute class (or SoapInclude if SoapRpc --
depending on your needs).

Should fix you up ....

Alex


I am trying to return a custom object from a web service, and get this
very
cryptic message.

System.InvalidOperationException: There was an error generating
the
XML document. --->
System.InvalidOperationException: The type myobject[]
may
not
be used in this context.

What does it mean?

The object I am returning has a couple of fields, plus an array containing
objects. The error message indicates a problem with creating xml
for
 
J

Jeremy

Easy for you to say (g). I've tried xmlinclude and xmlincludeattribute, to
no avail. Seems to be some confusion about whether I should use gettype()
or typeof(), but have tried both. I added the "type:=" construct, but that
didn't matter one way or the other. What a quaint and convoluted language
MS has produced. - Jeremy
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top