调用 Web 服务方法时出现 PlatformNotSupportedException
好吧,我真的被这个难住了。我有这个 Compact Framework 应用程序,它调用您的标准 .NET Web 服务。该软件已经运行良好一段时间了,但最近我们被要求让该软件在另一台 Windows CE 设备上运行。
这个新设备似乎是在韩国制造的,并且有一些奇怪/有缺陷的默认配置。控制面板上的区域设置显示区域设置已设置为英语(美国),并且用户界面语言和输入语言设置也设置了此值。
但还是有一些奇怪的问题。在 Windows 资源管理器中,用于分隔文件夹的常用“\”字符显示为划掉的 W。小输入面板上有一些字符也是错误的,有些字符看起来明显是韩文。
所有这一切的问题是,由于某种原因,当调用返回 DataSet 的 Web 服务方法时,我收到 PlatformNotSupportedException。在调试器上,我可以看到 CurrentUICulture 已正确设置为“en-US”,但不知何故,这并不能阻止程序遇到此问题。
我认为设备上安装的韩语与 Web 服务的文化配置冲突,但我不知道详细信息,也不知道如何修复它。任何帮助将不胜感激。谢谢。
这是完整的堆栈跟踪:
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)
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 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尝试使用的区域性不是中性区域性,并且设备操作系统不支持底层 Win32 区域设置。无论如何,对于 Web 服务,您不想使用不变的文化吗?
编辑:
DataSet
的架构需要通过 Microsoft 架构扩展来指定区域性。尝试将命名空间声明添加到您的架构中,并将属性
添加到表示
DataSet
根的xs:element
中,以强制使用不变区域性;非空字符串值将传递给CultureInfo(string)
构造函数。否则,如果该属性存在,则将使用设备当前的区域设置。 如果这两个属性都不存在,则会将其硬编码为
LCID 0x0409
,即美国英语。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 declarationto your schema, and the attribute
to the
xs:element
that represents the root of theDataSet
, to force the use of the invariant culture; a non-empty string value will be passed to theCultureInfo(string)
constructor. Otherwise, if the attributeis 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.您需要从 CSproj 属性构建设置中将目标平台更改为 X64 或 X32,或者只需从调试窗口选项下的异常设置中关闭所述 System.PlatformNotSupportedException 即可。
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.