all groups > dotnet web services > february 2008 >
You're in the

dotnet web services

group:

Problem with Nusoap & c#


Re: Problem with Nusoap & c# Daniel Cigic
2/26/2008 9:02:17 AM
dotnet web services:
Hi Bob,

For the cast to succeed both array must have the same number of dimensions
ant there must be an implicit or explicit conversion from the source element
type to the target element type.
You could use just one of the overloaded Array.Copy() methods. Looking at
you code I see
"return ((Categorie[])(results[0]));". Are you sure that you have array of
Categorie in first array - result[0] element?


Daniel

[quoted text, click to view]
Re: Problem with Nusoap & c# John Saunders [MVP]
2/26/2008 12:56:43 PM
[quoted text, click to view]

I've seen this when the serialization code is deserializing to a different
type than the proxy class is casting into. This has happened when the
serialization code (which is generated) is cached in one of the ASP.NET
caching locations (I forget how many there are), and then the code was
rebuilt, with a slightly different type.

You need to try deleting the cached version of the serialization code, then
rebuild the project. As I said, I never remember all the locations where
ASP.NET caches binaries for you, so someone else will have to help you
there. One thing that will help: is this a web project (File->New->Project),
or a web site (File->New->Web Site)?
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Problem with Nusoap & c# BOB Le Bricoleur
2/26/2008 3:13:44 PM
Hi,

I have a small web service written in PHP with NuSOAP which describes a
type "Categorie" and a function "GetCategories()".

I'm trying to access it with a C# application.

Here is the generated code where the error occurs:
-------------------------------------------------------------------
public Categorie[] GetCategories() {
object[] results = this.Invoke("GetCategories", new object[0]); //OK
return ((Categorie[])(results[0])); //ERR
}
-------------------------------------------------------------------


I get an error at runtime:
"System.InvalidCastException", can't cast an object of type "Categorie"
to an object of type "Categorie" !!

The invoke method works fine, all the data is in the results array.

Thanks for your help.

Re: Problem with Nusoap & c# BOB Le Bricoleur
2/26/2008 4:20:17 PM
Daniel Cigic a exposé le 26/02/2008 :
[quoted text, click to view]

I get the same error messages with Array.Copy()


[quoted text, click to view]

I am pretty sure; here is what the debugger gives for "results[0]":

results[0]:{Dimensions:[3]}
[0]:{ModuleAstuces.localhost.Categorie}
[1]:{ModuleAstuces.localhost.Categorie}
[2]:{ModuleAstuces.localhost.Categorie}


The code was generated by visual studio 2005, it should work without
modifying it. This is weird..

Re: Problem with Nusoap & c# BOB Le Bricoleur
2/27/2008 8:06:49 AM
John Saunders [MVP] a exprimé avec précision :
[quoted text, click to view]

I used "File->New->Project" to create a C# class library.

I tried to rename the Type "Categorie" in the web service, in case it
was aproblem of cache, but I still get the same error.

Re: Problem with Nusoap & c# BOB Le Bricoleur
2/27/2008 8:41:36 AM
When I create a new empty project, I add the web reference, it works
fine.

So the problem must be related to the fact that I dynamically load the
class library where I call the web service.

Re: Problem with Nusoap & c# [SOLVED] BOB Le Bricoleur
2/27/2008 9:47:47 AM
My mistake, I added a reference to the class library in the main
project.

Removing it solved it all.

Thanks for your help.

AddThis Social Bookmark Button