开发者

PlatformNotSupportedException when calling a Web Service method

开发者 https://www.devze.com 2023-01-30 03:43 出处:网络
Ok, I\'m really stumped with this one. I have this Compact Framework application which calls your standard .NET web service. This has been working pretty well for a 开发者_JAVA百科while, but recently

Ok, I'm really stumped with this one. I have this Compact Framework application which calls your standard .NET web service. This has been working pretty well for a 开发者_JAVA百科while, but recently we were asked to make this software work on another Windows CE device.

This new device seems to have been manufactured in Korea, and has some weird/buggy default configuration. Regional settings on the Control Panel show that the locale is set to English(United States) and the User Interface Language and Input Language settings have this value set as well.

There are some weird issues though. On Windows Explorer, the usual '\' characters that are used to separate folders, appear as a crossed-out W. The small input panel has some characters that are also wrong, some look clearly Korean.

The problem with all of this, is that for some reason I get a PlatformNotSupportedException, when calling a Web Service method that returns a DataSet. On the debugger I can see that the the CurrentUICulture is properly set to 'en-US', but somehow this doesn't keep the program from running into this issue.

I think that the Korean language installed on the device is conflicting with the culture configuration of the Web Service, but I don't have a clue about the details, and I don't know how I could fix it. Any help would be greatly appreciated. Thanks.

This is the full stack trace:

    System.PlatformNotSupportedException -    at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
   at System.Globalization.CultureInfo..ctor(String name)
   at System.Data.XSDSchema.HandleDataSet(XmlSchemaElement node, Boolean isNewDataSet)
   at System.Data.XSDSchema.LoadSchema(XmlSchemaSet schemaSet, DataSet ds)
   at System.Data.DataSet.ReadXSDSchema(XmlReader reader, Boolean denyResolving)
   at System.Data.DataSet.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving)
   at System.Data.DataSet.ReadXmlSerializable(XmlReader reader)
   at System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)
   at System.Xml.Serialization.XmlSerializationReader.DeserializeSerializableElement(LogicalType deserializeAs, Accessor accessor, Fixup fixup, Object fixupTarget, String identifier, Boolean emptyValue, Boolean nullValue)
   at System.Xml.Serialization.XmlSerializationReader.deserializeElement(Accessor accessor, Fixup fixup, Object fixupTarget)
   at System.Xml.Serialization.XmlSerializationReader.DeserializeElementMember(MemberValueCollection members, Object fixupTarget, Hashtable internalState, Boolean& firstElement)
   at System.Xml.Serialization.XmlSerializationReader.deserializeMembers(MemberValueCollection members, Object fixupTarget)
   at System.Xml.Serialization.XmlSerializationReader.DeserializeComplexElement(LogicalType deserializeAs, Accessor accessor, Fixup fixup, Object fixupTarget, String identifier, Boolean emptyValue, Boolean nullValue)
   at System.Xml.Serialization.XmlSerializationReader.deserializeElement(Accessor accessor, Fixup fixup, Object fixupTarget)
   at System.Xml.Serialization.XmlSerializationReader.DeserializeElementMember(MemberValueCollection members, Object fixupTarget, Hashtable internalState, Boolean& firstElement)
   at System.Xml.Serialization.XmlSerializationReader.deserializeMembers(MemberValueCollection members, Object fixupTarget)
   at System.Web.Services.Protocols.SoapMessageParser.execute()
   at System.Web.Services.Protocols.SoapMessageSerializer.Deserialize(XmlReader reader, SoapHttpClientProtocol client, LogicalSoapMethod soapMethod, Boolean soap12)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)


The culture you're trying to use is not a neutral culture and the underlying Win32 locale is not supported by the device's OS. In any case, for a web service, wouldn't you want to use the invariant culture?

EDIT: The schema for the DataSet needs to specify a culture by way of Microsoft schema extension. Try adding the namespace declaration

xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"

to your schema, and the attribute

msdata:Locale=""

to the xs:element that represents the root of the DataSet, to force the use of the invariant culture; a non-empty string value will be passed to the CultureInfo(string) constructor. Otherwise, if the attribute

msdata:UseCurrentLocale="true"

is present, whatever the device's current locale is will be used. If neither attribute is present, it's hardcoded to LCID 0x0409, which is US English.


You either need to change the target platform to X64 or X32 from your CSproj properties build settings or just simply turn off the said System.PlatformNotSupportedException from exception settings under debug windows option.

0

精彩评论

暂无评论...
验证码 换一张
取 消