Re: Error when WebMethod returns a jagged array
From: MikeL (MichaelLopez_at_inds.com)
Date: 02/09/05
- Next message: Bruce Johnson [C# MVP]: "Re: Error when WebMethod returns a jagged array"
- Previous message: Bruce Johnson [C# MVP]: "RE: dynamically invoking web service methods, how?"
- In reply to: Bruce Johnson [C# MVP]: "Re: Error when WebMethod returns a jagged array"
- Next in thread: Bruce Johnson [C# MVP]: "Re: Error when WebMethod returns a jagged array"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Feb 2005 09:50:26 -0500
Hi, Bruce. Thanks again for responding.
I found the .cs file. It was under <System Drive>\Documents and Setting\<My
Machine Name>\ASPNET\Local Settings\Temp.
I copied the source from that file into a new C# file in my project,
compiled the project, and the compile failed. The generated code tries to
assign string[] to a string, and vice versa.
Here's how the compile reads:
Preparing resources...
Updating references...
Performing main compilation...
c:\inetpub\wwwroot\jaggedarraytypes\codefile2.cs(19,6): warning CS0642:
Possible mistaken null statement
c:\inetpub\wwwroot\jaggedarraytypes\codefile2.cs(36,78): error CS0030:
Cannot convert type 'string[]' to 'string'
c:\inetpub\wwwroot\jaggedarraytypes\codefile2.cs(55,6): warning CS0642:
Possible mistaken null statement
c:\inetpub\wwwroot\jaggedarraytypes\codefile2.cs(71,80): error CS0030:
Cannot convert type 'string[]' to 'string'
c:\inetpub\wwwroot\jaggedarraytypes\codefile2.cs(115,6): warning CS0642:
Possible mistaken null statement
c:\inetpub\wwwroot\jaggedarraytypes\codefile2.cs(172,114): error CS0029:
Cannot implicitly convert type 'string' to 'string[]'
c:\inetpub\wwwroot\jaggedarraytypes\codefile2.cs(236,113): error CS0029:
Cannot implicitly convert type 'string' to 'string[]'
Build complete -- 4 errors, 3 warnings
Building satellite assemblies...
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
Here's a snippet of the generated code in the assembly that is pointed to by
the first error (I added the elipses). The error is in the
"WriteElementString" method call:
...
{
System.String[][] a =
(System.String[][])((System.String[][])o.@JaggedArray1);
if (a != null)
{
WriteStartElement(@"JaggedArray1",
@http://www.stoneeagle.com/RatingHub);
for (int ia = 0; ia < a.Length; ia++)
{
WriteElementString(@"string",
@"http://www.stoneeagle.com/RatingHub", ((System.String)a[ia])); // THIS
IS WHERE THE ERROR IS
}
WriteEndElement();
}
}
...
I understand why the compile failed, but I don't know what I need to do in
the XSD.EXE-generated class file to make this work. Any suggestions?
I have looked at the "Contract-First WSDL" code generator by Thinktecture
and see that their code generates Collections instead of jagged arrays.
Have you any experience serializing Collections and do you think that that's
a better solution?
Thanks again,
Mike
"Bruce Johnson [C# MVP]" <bruce@spammenot.objectsharp.com> wrote in message
news:5C5E47BB-487F-4E78-AEF6-C35FCC57D8E1@microsoft.com...
> 1. Don't know for sure if the code that xsd generated for jagged arrays
> is
> causing the problem. It could be something as simple as a property name
> that
> happens to be a keyword in C#. I don't see that in your code, but then
> again, I can't see all of the code.
>
> 2. It's the web.config file on the server that gets changed. You might
> have to search around for the persisted file. I found it a challenge to
> find
> the first time.
>
> 3. It's difficult to come up with a solution until I see why the file
> isn't
> compiling. And I suspect when you do see it, the reason will be obvious.
>
> Bruce Johnson [C# MVP]
> http://www.objectsharp.com/blogs/bruce
>
> "MikeL" wrote:
>
>> Hi, Bruce. Thanks for responding.
>>
>> That certainly addresses my problem. If you don't mind I have three
>> additional questions:
>>
>> 1) Why would XSD.exe generate jagged arrays if the generated code can't
>> be
>> compiled?
>> 2) The article states to change the app's .config file. Is this the
>> web.config file of my webservice project? The reason I ask is because
>> that's
>> exactly what I changed and nothing peristed.
>> 3) The article offered no solution. Do you have any suggestions for a
>> solution?
>>
>> Thanks again,
>>
>> Mike
>>
>> "Bruce Johnson [C# MVP]" <bruce@spammenot.objectsharp.com> wrote in
>> message
>> news:3E23F7BC-DDC7-445F-BD04-48D3F886BEAD@microsoft.com...
>> > This type of error is usually indicative of something bad going on when
>> > the
>> > web service tries to generate the class that is used to serialize the
>> > incoming and outgoing messages. Check out
>> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp
>> > to a description of how to identify these sorts of problems, paying
>> > particular attention to the section towards the bottom that describes
>> > how
>> > to
>> > keep the compiled code around.
>> >
>> > Hope this helps.
>> >
>> > Bruce Johnson [C# MVP]
>> > http://www.objectsharp.com/blogs/bruce
>> >
>> > "MikeL" wrote:
>> >
>> >> Hello.
>> >>
>> >> I've been getting an error message like the following when testing a
>> >> webservice that I'm creating:
>> >>
>> >> "File or assembly name 8rsiphqb.dll, or one of its
>> >> dependencies,
>> >> was not found."
>> >>
>> >> Each time I refresh the page the .dll name changes, which tells me
>> >> that
>> >> the
>> >> CLR is generating this .dll (right?)
>> >>
>> >> I think I narrowed down the problem: It seems only to happen when the
>> >> return
>> >> type of the WebMethod contains a jagged array. Here's what the XSD.exe
>> >> utility generated from my schema:
>> >>
>> >> [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.myService.com/RatingHub")]
>> >> [System.Xml.Serialization.XmlRootAttribute(Namespace="http://www.myService.com/RatingHub",
>> >> IsNullable=false)]
>> >>
>> >> public class scPlan
>> >>
>> >> {
>> >>
>> >>
>> >> /// <remarks/>
>> >>
>> >> [System.Xml.Serialization.XmlArrayItemAttribute(typeof(scTermRate),
>> >> IsNullable=false)]
>> >>
>> >> public scTermRate[][] scTermRates;
>> >>
>> >>
>> >> /// <remarks/>
>> >>
>> >> [System.Xml.Serialization.XmlArrayItemAttribute(typeof(scSurcharge),
>> >> IsNullable=false)]
>> >>
>> >> public scSurcharge[][] scSurcharges;
>> >>
>> >>
>> >> /// <remarks/>
>> >>
>> >> [System.Xml.Serialization.XmlAttributeAttribute()]
>> >>
>> >> public string code;
>> >>
>> >>
>> >> /// <remarks/>
>> >>
>> >> [System.Xml.Serialization.XmlAttributeAttribute()]
>> >>
>> >> public string description;
>> >>
>> >> }
>> >>
>> >> When I set a breakpoint on the first line of the WebMethod in the
>> >> .asmx
>> >> file
>> >> it is never reached, the error is generated in the browser.
>> >>
>> >> Does anyone know what's going on?
>> >>
>> >> Thanks in advance,
>> >>
>> >> Mike
>> >>
>> >>
>> >>
>>
>>
>>
- Next message: Bruce Johnson [C# MVP]: "Re: Error when WebMethod returns a jagged array"
- Previous message: Bruce Johnson [C# MVP]: "RE: dynamically invoking web service methods, how?"
- In reply to: Bruce Johnson [C# MVP]: "Re: Error when WebMethod returns a jagged array"
- Next in thread: Bruce Johnson [C# MVP]: "Re: Error when WebMethod returns a jagged array"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|