DefaultValue in DataObject used in Webservice [modified]
-
Hi we have a data object that is used in WindowsForm applications and should now be used also in a webservice. The data object has fields that have the attribute DefaultValue. With this attribute, accessing the web service fails with an error. Without the attribute it works. This is the code (example code that causes the same problem):
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service ()
{
}\[WebMethod\] public Foo Test1(Foo foo) { return foo; }
}
public class Foo
{
private char bar;\[System.ComponentModel.DefaultValue(',')\] public char Bar { get { return bar; } set { bar = value; } }
}
And this is the error:
Server Error in '/TestWebService1' Application. -------------------------------------------------------------------------------- The default value type, System.Char, is unsupported. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: The default value type, System.Char, is unsupported. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
How can I fix this without removing the attrribute, as it is used for changing the properties of a Control that is using this data object in the Visual Studio. Thanks and greets Roland Additional Note: The XmlIgnore attribute should not be used as it should be still serializable to an xml file.
Hi! I'm a signature virus. Copy me into your sig file and help me spread!
Follow your Euro notes in their tracks
modified on Thursday, February 5, 2009 8:26 AM