HELP Problem serializing a structure

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hello,

I am having a problem trying to serialize this simple structure, I use it
in a collection class that derives from CollectionBase but I noticed that at
least for now the serialization exception ocurrs when i try to serialize
this structure (see below). The idea is that it would be serialized to:

< Param type="..." method="Get" required="true">something</Param>



I use the following to serialize:

WizarParameter wpar = new WizardParameter(typeof(int),
WizardParameterMethod.Get, true, "something");
StringWriter sw = new StringWriter();
XmlSerializer ser = new XmlSerializer(typeof(WizardParameter));
ser.Serialize(sw, wpar);

[Serializable]
[XmlRoot("Param")]
public struct WizardParameter

{

/// The system type contained by this parameter
[XmlAttribute("type")]
public System.Type Type;

/// The method that should be used to pass this paramete
[XmlAttribute("method")]
public WizardParameterMethod Method; /// enumeration

/// Whether the parameter is required or optional

[XmlAttribute("required")]
public bool IsRequired;

[XmlElement("key")]
public string Key;

public WizardParameter(Type type, WizardParameterMethod method, bool
required, string key)

{

this.Type = type;

this.Method = method;

this.IsRequired = required;

this.Key = key;

}

}


.



Relevant Pages

  • Re: HELP Problem serializing a structure
    ... actual exception object generated told me the culprit was the Type property. ... For some reason it is not able to serialize a member of type System.Type. ... >> public struct WizardParameter ... >> required, string key) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: IExtender Collection property Serialization problems
    ... attribute the collection does not serialize at all. ... you'll see that I made the Collection Items class (FooBar) inherit from ... I did try not implementing the AddRangemethod in the collection class, ... bool IExtenderProvider.CanExtend(object extendee) ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)
  • Re: Serializing Collections with Interface members
    ... to serialize a collection, all object in the collection must be ... >I have a collection class and in order to make it type safe etc, ... > and retrive members of Interface types. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: My component does not serialize CollectionBase derived property?
    ... the collection class must implement an indexer. ... > I've a CustomClass derives from Object that is marked as... ... >>> not serialize my component's property? ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)
  • Re: IExtender Collection property Serialization problems
    ... You can serialize non-IComponent classes in a collection, ... But I have never tried an IExtenderProvider ... Non-sited IComponent objects will not serialize ... I did try not implementing the AddRangemethod in the collection class, ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)