473,762 Members | 7,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web Method returns array of custom type : casting error

My ASP.NET Web Service project has a Web Method that returns an array filled
with instances of a custom class.

The custom class is defined in a Class Library that is included in the
web-service project.

The same class lib is included in the ASP.NET Web Application that calls the
web-method

I can successfully call the web-method with

object[] a = WebReference.We bService.WebMet hod();

but when I attempt

myClass element = (myClass) a[i];

I receive the runtime error

"Specified cast is not valid."



Nov 23 '05 #1
7 4747
What the web method (actually the method from proxy class) is returning is a
proxy-type, and not the type that web service originally returned. You have
two choices:

1. Use the proxy type as-is. Since this was generated class, it will be
close to what the web service returned, sans any methods.

2. Manually edit the proxy class (found in webreferences folder of your web
site, with the same name as the reference page), and remove the proxy type,
and include the actual type in the cs file. Then add the corresponding using
statement as well.
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
My ASP.NET Web Service project has a Web Method that returns an array filled with instances of a custom class.

The custom class is defined in a Class Library that is included in the
web-service project.

The same class lib is included in the ASP.NET Web Application that calls the web-method

I can successfully call the web-method with

object[] a = WebReference.We bService.WebMet hod();

but when I attempt

myClass element = (myClass) a[i];

I receive the runtime error

"Specified cast is not valid."


Nov 23 '05 #2
Hi Manohar, and thanks for the response.

<<<
1. Use the proxy type as-is. Since this was generated class, it will be
close to what the web service returned, sans any methods.

My custom class is very simple. Two private fields. Two properties to
read-access the private fields. Two constructors (default, and one that
sets the two fields' values).

Are you saying that the proxy type will contain the data that my custom
class contains , but the two properties will not be available ?

So, I access the data like this:

a[i].Field1
a[i].Field2
<<<
2. Manually edit the proxy class (found in webreferences folder of your web
site, with the same name as the reference page), and remove the proxy type,
and include the actual type in the cs file. Then add the corresponding using
statement as well.

I'm not sure exactly what to do here.

Looking at my web-application in Visual Studio, and clicking on the
web-reference, a number of expandable nodes are shown: these appear to be
all of the types that my web-service references. Among them is listed the
name of my custom class -- but the first character is in lower case. In the
tree that expands from that node are listed my class' fields, construtors,
and properties exactly as I've defined them.

I'm looking at the contents of the "Web References" folder underneath my
web-app's physical folder: Reference.cs, Reference.map,
<web-service-name>.disco, <web-service-name>.wsdl

These files all look very dangerous to edit.
"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:uA******** ********@TK2MSF TNGP10.phx.gbl. .. What the web method (actually the method from proxy class) is returning is
a
proxy-type, and not the type that web service originally returned. You
have
two choices:

1. Use the proxy type as-is. Since this was generated class, it will be
close to what the web service returned, sans any methods.

2. Manually edit the proxy class (found in webreferences folder of your
web
site, with the same name as the reference page), and remove the proxy
type,
and include the actual type in the cs file. Then add the corresponding
using
statement as well.
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
My ASP.NET Web Service project has a Web Method that returns an array

filled
with instances of a custom class.

The custom class is defined in a Class Library that is included in the
web-service project.

The same class lib is included in the ASP.NET Web Application that calls

the
web-method

I can successfully call the web-method with

object[] a = WebReference.We bService.WebMet hod();

but when I attempt

myClass element = (myClass) a[i];

I receive the runtime error

"Specified cast is not valid."



Nov 23 '05 #3
I am saying, your proxy type is identical to your custom type (almost),
except it will be in another namespace -- same as that of the proxy class.
So, by doing a manual changes, you are tricking SOAP to think that it is
actually deserializing to proxy type. As long as the names and types are
same, it will work.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:u%******** **********@TK2M SFTNGP10.phx.gb l...
Hi Manohar, and thanks for the response.

<<<
1. Use the proxy type as-is. Since this was generated class, it will be
close to what the web service returned, sans any methods.

My custom class is very simple. Two private fields. Two properties to
read-access the private fields. Two constructors (default, and one that
sets the two fields' values).

Are you saying that the proxy type will contain the data that my custom
class contains , but the two properties will not be available ?

So, I access the data like this:

a[i].Field1
a[i].Field2
<<<
2. Manually edit the proxy class (found in webreferences folder of your web site, with the same name as the reference page), and remove the proxy type, and include the actual type in the cs file. Then add the corresponding using statement as well.
I'm not sure exactly what to do here.

Looking at my web-application in Visual Studio, and clicking on the
web-reference, a number of expandable nodes are shown: these appear to be
all of the types that my web-service references. Among them is listed the
name of my custom class -- but the first character is in lower case. In the tree that expands from that node are listed my class' fields, construtors,
and properties exactly as I've defined them.

I'm looking at the contents of the "Web References" folder underneath my
web-app's physical folder: Reference.cs, Reference.map,
<web-service-name>.disco, <web-service-name>.wsdl

These files all look very dangerous to edit.
"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:uA******** ********@TK2MSF TNGP10.phx.gbl. ..
What the web method (actually the method from proxy class) is returning

is a
proxy-type, and not the type that web service originally returned. You
have
two choices:

1. Use the proxy type as-is. Since this was generated class, it will be
close to what the web service returned, sans any methods.

2. Manually edit the proxy class (found in webreferences folder of your
web
site, with the same name as the reference page), and remove the proxy
type,
and include the actual type in the cs file. Then add the corresponding
using
statement as well.
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
My ASP.NET Web Service project has a Web Method that returns an array

filled
with instances of a custom class.

The custom class is defined in a Class Library that is included in the
web-service project.

The same class lib is included in the ASP.NET Web Application that
calls the
web-method

I can successfully call the web-method with

object[] a = WebReference.We bService.WebMet hod();

but when I attempt

myClass element = (myClass) a[i];

I receive the runtime error

"Specified cast is not valid."




Nov 23 '05 #4
Ok. I edited Reference.cs so that my custom type is explicitly declared
using the class library namespace:

used to be : public MyCustomClass Method1() {

changed to: public MyCustomClassLi brary.MyCustomC lass Method1() {
Now what happens is that I receive no compile-time nor run-time errors, but
on the web-app side, properties of an instance of MyCustomClass are always
null, no matter what values MyWebService.Me thod1() has set them to.
so ...

object[] array = MyWebReference. Method1();
(MyCustomClass) element = array[0];
String s1 = element.Field1;
String s2 = element.Field2;

element.Field1 and element.Field2 are always null,

"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:eR******** ******@TK2MSFTN GP12.phx.gbl...
I am saying, your proxy type is identical to your custom type (almost),
except it will be in another namespace -- same as that of the proxy class.
So, by doing a manual changes, you are tricking SOAP to think that it is
actually deserializing to proxy type. As long as the names and types are
same, it will work.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:u%******** **********@TK2M SFTNGP10.phx.gb l...
Hi Manohar, and thanks for the response.

<<<
1. Use the proxy type as-is. Since this was generated class, it will be
close to what the web service returned, sans any methods.
>>>


My custom class is very simple. Two private fields. Two properties to
read-access the private fields. Two constructors (default, and one that
sets the two fields' values).

Are you saying that the proxy type will contain the data that my custom
class contains , but the two properties will not be available ?

So, I access the data like this:

a[i].Field1
a[i].Field2
<<<
2. Manually edit the proxy class (found in webreferences folder of your

web
site, with the same name as the reference page), and remove the proxy

type,
and include the actual type in the cs file. Then add the corresponding

using
statement as well.
>>>


I'm not sure exactly what to do here.

Looking at my web-application in Visual Studio, and clicking on the
web-reference, a number of expandable nodes are shown: these appear to be
all of the types that my web-service references. Among them is listed
the
name of my custom class -- but the first character is in lower case. In

the
tree that expands from that node are listed my class' fields,
construtors,
and properties exactly as I've defined them.

I'm looking at the contents of the "Web References" folder underneath my
web-app's physical folder: Reference.cs, Reference.map,
<web-service-name>.disco, <web-service-name>.wsdl

These files all look very dangerous to edit.
"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:uA******** ********@TK2MSF TNGP10.phx.gbl. ..
> What the web method (actually the method from proxy class) is returning is > a
> proxy-type, and not the type that web service originally returned. You
> have
> two choices:
>
> 1. Use the proxy type as-is. Since this was generated class, it will be
> close to what the web service returned, sans any methods.
>
> 2. Manually edit the proxy class (found in webreferences folder of your
> web
> site, with the same name as the reference page), and remove the proxy
> type,
> and include the actual type in the cs file. Then add the corresponding
> using
> statement as well.
>
>
> --
> Manohar Kamath
> Editor, .netWire
> www.dotnetwire.com
>
>
> "John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
> news:%2******** **********@TK2M SFTNGP09.phx.gb l...
>> My ASP.NET Web Service project has a Web Method that returns an array
> filled
>> with instances of a custom class.
>>
>> The custom class is defined in a Class Library that is included in the
>> web-service project.
>>
>> The same class lib is included in the ASP.NET Web Application that calls > the
>> web-method
>>
>> I can successfully call the web-method with
>>
>> object[] a = WebReference.We bService.WebMet hod();
>>
>> but when I attempt
>>
>> myClass element = (myClass) a[i];
>>
>> I receive the runtime error
>>
>> "Specified cast is not valid."
>>
>>
>>
>>
>>
>>
>>
>
>



Nov 23 '05 #5
I think you misunderstood me...

In the reference.cs, DELETE the custom type MyCustomClass. Then, add the
using statement with the namespace MyCustomClassLi brary. You should not have
to change anything else.
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:e1******** ******@TK2MSFTN GP12.phx.gbl...
Ok. I edited Reference.cs so that my custom type is explicitly declared
using the class library namespace:

used to be : public MyCustomClass Method1() {

changed to: public MyCustomClassLi brary.MyCustomC lass Method1() {
Now what happens is that I receive no compile-time nor run-time errors, but on the web-app side, properties of an instance of MyCustomClass are always
null, no matter what values MyWebService.Me thod1() has set them to.
so ...

object[] array = MyWebReference. Method1();
(MyCustomClass) element = array[0];
String s1 = element.Field1;
String s2 = element.Field2;

element.Field1 and element.Field2 are always null,

"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:eR******** ******@TK2MSFTN GP12.phx.gbl...
I am saying, your proxy type is identical to your custom type (almost),
except it will be in another namespace -- same as that of the proxy class. So, by doing a manual changes, you are tricking SOAP to think that it is
actually deserializing to proxy type. As long as the names and types are same, it will work.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:u%******** **********@TK2M SFTNGP10.phx.gb l...
Hi Manohar, and thanks for the response.

<<<
1. Use the proxy type as-is. Since this was generated class, it will be
close to what the web service returned, sans any methods.
>>>

My custom class is very simple. Two private fields. Two properties to
read-access the private fields. Two constructors (default, and one that sets the two fields' values).

Are you saying that the proxy type will contain the data that my custom
class contains , but the two properties will not be available ?

So, I access the data like this:

a[i].Field1
a[i].Field2
<<<
2. Manually edit the proxy class (found in webreferences folder of your

web
site, with the same name as the reference page), and remove the proxy

type,
and include the actual type in the cs file. Then add the corresponding

using
statement as well.
>>>

I'm not sure exactly what to do here.

Looking at my web-application in Visual Studio, and clicking on the
web-reference, a number of expandable nodes are shown: these appear to be all of the types that my web-service references. Among them is listed
the
name of my custom class -- but the first character is in lower case. In
the
tree that expands from that node are listed my class' fields,
construtors,
and properties exactly as I've defined them.

I'm looking at the contents of the "Web References" folder underneath
my web-app's physical folder: Reference.cs, Reference.map,
<web-service-name>.disco, <web-service-name>.wsdl

These files all look very dangerous to edit.
"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:uA******** ********@TK2MSF TNGP10.phx.gbl. ..
> What the web method (actually the method from proxy class) is returning is
> a
> proxy-type, and not the type that web service originally returned.

You > have
> two choices:
>
> 1. Use the proxy type as-is. Since this was generated class, it will be > close to what the web service returned, sans any methods.
>
> 2. Manually edit the proxy class (found in webreferences folder of your > web
> site, with the same name as the reference page), and remove the proxy
> type,
> and include the actual type in the cs file. Then add the corresponding > using
> statement as well.
>
>
> --
> Manohar Kamath
> Editor, .netWire
> www.dotnetwire.com
>
>
> "John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
> news:%2******** **********@TK2M SFTNGP09.phx.gb l...
>> My ASP.NET Web Service project has a Web Method that returns an array > filled
>> with instances of a custom class.
>>
>> The custom class is defined in a Class Library that is included in the >> web-service project.
>>
>> The same class lib is included in the ASP.NET Web Application that

calls
> the
>> web-method
>>
>> I can successfully call the web-method with
>>
>> object[] a = WebReference.We bService.WebMet hod();
>>
>> but when I attempt
>>
>> myClass element = (myClass) a[i];
>>
>> I receive the runtime error
>>
>> "Specified cast is not valid."
>>
>>
>>
>>
>>
>>
>>
>
>



Nov 23 '05 #6
Ahh, I see. The problem is that the MyCustomClass stub in References.cs
causes the compiler to think that web-method return types of MyCustomClass
originate in the web-service rather than in MyCustomClassLi brary.

Correct ?

"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:em******** ******@TK2MSFTN GP10.phx.gbl...
I think you misunderstood me...

In the reference.cs, DELETE the custom type MyCustomClass. Then, add the
using statement with the namespace MyCustomClassLi brary. You should not
have
to change anything else.
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:e1******** ******@TK2MSFTN GP12.phx.gbl...
Ok. I edited Reference.cs so that my custom type is explicitly declared
using the class library namespace:

used to be : public MyCustomClass Method1() {

changed to: public MyCustomClassLi brary.MyCustomC lass Method1() {
Now what happens is that I receive no compile-time nor run-time errors,

but
on the web-app side, properties of an instance of MyCustomClass are
always
null, no matter what values MyWebService.Me thod1() has set them to.
so ...

object[] array = MyWebReference. Method1();
(MyCustomClass) element = array[0];
String s1 = element.Field1;
String s2 = element.Field2;

element.Field1 and element.Field2 are always null,

"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:eR******** ******@TK2MSFTN GP12.phx.gbl...
>I am saying, your proxy type is identical to your custom type (almost),
> except it will be in another namespace -- same as that of the proxy class. > So, by doing a manual changes, you are tricking SOAP to think that it
> is
> actually deserializing to proxy type. As long as the names and types are > same, it will work.
>
> --
> Manohar Kamath
> Editor, .netWire
> www.dotnetwire.com
>
>
> "John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
> news:u%******** **********@TK2M SFTNGP10.phx.gb l...
>> Hi Manohar, and thanks for the response.
>>
>> <<<
>> 1. Use the proxy type as-is. Since this was generated class, it will
>> be
>> close to what the web service returned, sans any methods.
>> >>>
>>
>> My custom class is very simple. Two private fields. Two properties
>> to
>> read-access the private fields. Two constructors (default, and one that >> sets the two fields' values).
>>
>> Are you saying that the proxy type will contain the data that my
>> custom
>> class contains , but the two properties will not be available ?
>>
>> So, I access the data like this:
>>
>> a[i].Field1
>> a[i].Field2
>>
>>
>> <<<
>> 2. Manually edit the proxy class (found in webreferences folder of
>> your
> web
>> site, with the same name as the reference page), and remove the proxy
> type,
>> and include the actual type in the cs file. Then add the corresponding
> using
>> statement as well.
>> >>>
>>
>> I'm not sure exactly what to do here.
>>
>> Looking at my web-application in Visual Studio, and clicking on the
>> web-reference, a number of expandable nodes are shown: these appear to be >> all of the types that my web-service references. Among them is listed
>> the
>> name of my custom class -- but the first character is in lower case. In > the
>> tree that expands from that node are listed my class' fields,
>> construtors,
>> and properties exactly as I've defined them.
>>
>> I'm looking at the contents of the "Web References" folder underneath my >> web-app's physical folder: Reference.cs, Reference.map,
>> <web-service-name>.disco, <web-service-name>.wsdl
>>
>> These files all look very dangerous to edit.
>>
>>
>> "Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
>> news:uA******** ********@TK2MSF TNGP10.phx.gbl. ..
>> > What the web method (actually the method from proxy class) is returning > is
>> > a
>> > proxy-type, and not the type that web service originally returned. You >> > have
>> > two choices:
>> >
>> > 1. Use the proxy type as-is. Since this was generated class, it will be >> > close to what the web service returned, sans any methods.
>> >
>> > 2. Manually edit the proxy class (found in webreferences folder of your >> > web
>> > site, with the same name as the reference page), and remove the
>> > proxy
>> > type,
>> > and include the actual type in the cs file. Then add the corresponding >> > using
>> > statement as well.
>> >
>> >
>> > --
>> > Manohar Kamath
>> > Editor, .netWire
>> > www.dotnetwire.com
>> >
>> >
>> > "John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
>> > news:%2******** **********@TK2M SFTNGP09.phx.gb l...
>> >> My ASP.NET Web Service project has a Web Method that returns an array >> > filled
>> >> with instances of a custom class.
>> >>
>> >> The custom class is defined in a Class Library that is included in the >> >> web-service project.
>> >>
>> >> The same class lib is included in the ASP.NET Web Application that
> calls
>> > the
>> >> web-method
>> >>
>> >> I can successfully call the web-method with
>> >>
>> >> object[] a = WebReference.We bService.WebMet hod();
>> >>
>> >> but when I attempt
>> >>
>> >> myClass element = (myClass) a[i];
>> >>
>> >> I receive the runtime error
>> >>
>> >> "Specified cast is not valid."
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 23 '05 #7
Yes... by removing the custom type, you are actually returning from the
proxy class, an object which is the same type the web service returns.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:uR******** ******@TK2MSFTN GP14.phx.gbl...
Ahh, I see. The problem is that the MyCustomClass stub in References.cs
causes the compiler to think that web-method return types of MyCustomClass
originate in the web-service rather than in MyCustomClassLi brary.

Correct ?

"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:em******** ******@TK2MSFTN GP10.phx.gbl...
I think you misunderstood me...

In the reference.cs, DELETE the custom type MyCustomClass. Then, add the
using statement with the namespace MyCustomClassLi brary. You should not
have
to change anything else.
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:e1******** ******@TK2MSFTN GP12.phx.gbl...
Ok. I edited Reference.cs so that my custom type is explicitly declared
using the class library namespace:

used to be : public MyCustomClass Method1() {

changed to: public MyCustomClassLi brary.MyCustomC lass Method1() {
Now what happens is that I receive no compile-time nor run-time errors,

but
on the web-app side, properties of an instance of MyCustomClass are
always
null, no matter what values MyWebService.Me thod1() has set them to.
so ...

object[] array = MyWebReference. Method1();
(MyCustomClass) element = array[0];
String s1 = element.Field1;
String s2 = element.Field2;

element.Field1 and element.Field2 are always null,

"Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
news:eR******** ******@TK2MSFTN GP12.phx.gbl...
>I am saying, your proxy type is identical to your custom type (almost), > except it will be in another namespace -- same as that of the proxy

class.
> So, by doing a manual changes, you are tricking SOAP to think that it
> is
> actually deserializing to proxy type. As long as the names and types

are
> same, it will work.
>
> --
> Manohar Kamath
> Editor, .netWire
> www.dotnetwire.com
>
>
> "John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
> news:u%******** **********@TK2M SFTNGP10.phx.gb l...
>> Hi Manohar, and thanks for the response.
>>
>> <<<
>> 1. Use the proxy type as-is. Since this was generated class, it will
>> be
>> close to what the web service returned, sans any methods.
>> >>>
>>
>> My custom class is very simple. Two private fields. Two properties
>> to
>> read-access the private fields. Two constructors (default, and one

that
>> sets the two fields' values).
>>
>> Are you saying that the proxy type will contain the data that my
>> custom
>> class contains , but the two properties will not be available ?
>>
>> So, I access the data like this:
>>
>> a[i].Field1
>> a[i].Field2
>>
>>
>> <<<
>> 2. Manually edit the proxy class (found in webreferences folder of
>> your
> web
>> site, with the same name as the reference page), and remove the proxy > type,
>> and include the actual type in the cs file. Then add the corresponding > using
>> statement as well.
>> >>>
>>
>> I'm not sure exactly what to do here.
>>
>> Looking at my web-application in Visual Studio, and clicking on the
>> web-reference, a number of expandable nodes are shown: these appear to
be
>> all of the types that my web-service references. Among them is
listed >> the
>> name of my custom class -- but the first character is in lower case.

In
> the
>> tree that expands from that node are listed my class' fields,
>> construtors,
>> and properties exactly as I've defined them.
>>
>> I'm looking at the contents of the "Web References" folder underneath my
>> web-app's physical folder: Reference.cs, Reference.map,
>> <web-service-name>.disco, <web-service-name>.wsdl
>>
>> These files all look very dangerous to edit.
>>
>>
>> "Manohar Kamath" <mk*****@TAKETH ISOUTkamath.com > wrote in message
>> news:uA******** ********@TK2MSF TNGP10.phx.gbl. ..
>> > What the web method (actually the method from proxy class) is

returning
> is
>> > a
>> > proxy-type, and not the type that web service originally returned.

You
>> > have
>> > two choices:
>> >
>> > 1. Use the proxy type as-is. Since this was generated class, it
will be
>> > close to what the web service returned, sans any methods.
>> >
>> > 2. Manually edit the proxy class (found in webreferences folder of

your
>> > web
>> > site, with the same name as the reference page), and remove the
>> > proxy
>> > type,
>> > and include the actual type in the cs file. Then add the

corresponding
>> > using
>> > statement as well.
>> >
>> >
>> > --
>> > Manohar Kamath
>> > Editor, .netWire
>> > www.dotnetwire.com
>> >
>> >
>> > "John Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
>> > news:%2******** **********@TK2M SFTNGP09.phx.gb l...
>> >> My ASP.NET Web Service project has a Web Method that returns an

array
>> > filled
>> >> with instances of a custom class.
>> >>
>> >> The custom class is defined in a Class Library that is included
in the
>> >> web-service project.
>> >>
>> >> The same class lib is included in the ASP.NET Web Application

that > calls
>> > the
>> >> web-method
>> >>
>> >> I can successfully call the web-method with
>> >>
>> >> object[] a = WebReference.We bService.WebMet hod();
>> >>
>> >> but when I attempt
>> >>
>> >> myClass element = (myClass) a[i];
>> >>
>> >> I receive the runtime error
>> >>
>> >> "Specified cast is not valid."
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 23 '05 #8

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

Similar topics

3
3151
by: Stefan Weiss | last post by:
Hi. The manual for pg_fetch_result() reads: | All forms of integer types are returned as integer values. All | forms of float, and real types are returned as float values. Boolean | is returned as "t" or "f". All other types, including arrays are | returned as strings formatted in the same default PostgreSQL manner | that you would see in the psql program.
1
2076
by: J. Campbell | last post by:
I have a feeling that I'm doing things all ass-backwards (again ;-), and would like some advice. What I want to do is: put some data to memory and then access that memory space as an array of data-types of my choosing (eg an array of char, short, or int). The application has to do with generating checksum-type values for files or strings, so speed is important, as I just want to quickly get this value then move on to the next task. As...
0
2306
by: Bartas | last post by:
Hi, I'am writting a simple SOAP client in python (2.4) using SOAPpy lib. I've met with this problem: when I want to send a list of complex type using some method from WebService(java,WAS), I'v got an exception:
11
4468
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to accomplish. // - - - - - - - - begin code - - - - - - - typedef int sm_t; typedef int bg_t; sm_t sm; bg_t bg;
18
4743
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
0
1685
by: george_Martinho | last post by:
It seems that the ASP.NET Microsoft team didn't think about this!! The profilemanager class has the following methods: - DeleteInactiveProfiles. Enables you to delete all profiles older than a specified date. - DeleteProfile. Enables you to delete a profile associated with a specified username. - DeleteProfiles. Enables you to delete a set of profiles. - FindInactiveProfilesByUserName. Returns a collection of ProfileInfo
2
2169
by: SM | last post by:
Hi, I have a web service method developed in .Net 1.1 where both http get and post protocols are enabled. the problem is that , when i access my web method from ie window like http://localhost/ws/FindName.asmx/FindName?name="test"&age=30 it returns results in xml , however , if tried to call the same method in the following fashion http://localhost/ws/FindName.asmx/FindName?name="test"&age=
15
1257
by: Sunburned Surveyor | last post by:
I'm a Java developer in the process of writing a class library in C#, so please bear with me. I'm trying to write a method that can return a generic Object OR a Decimal value. In Java I would just have the method return an Object, since all Java primitive data types have Object wrappers like Integer and Double. If I have a method signature that returns Object in C#, can I return a Decimal value within the method body? I was looking...
12
2168
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, I have a class which "BiologySequence" which looks about like this. public class BiologySequence { private string _Sequence; public string Sequence {
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.