asp.net - Custom Type within ArrayList inside of the user profile in C# -


When trying to save a custom square within my ArrayList in my user profile, I get the following error:

There was an error in creating the XML document. ---> System. Resident Operation Exception: Type com.xxx.MyDataClass was not required. Use the XmlInclude or the SoapInclude attribute to specify the types that are not known statically.

Something like this in my web.config:

  & lt; Profile enabled = "true" auto-saved = "wrong" default provider = "xxxxxxProvider" & gt; & Lt; Properties & gt; & Lt; Add name = "mydata" type = "System.Collections.ArrayList" /> & Lt; / Properties & gt; & Lt; / Profile & gt;  

I'm trying to store a class named MyDataClass (something like) in an ArrayList in MyData. When I save, I receive an error above Class MeadataClass has only two members , Both are set as 'string'.

I think I have to tell that class is self-actualizing, but I'm not sure how.

Here is the square:

  namespace com.xxxx.DataClasses {public class MyDataClass: ISerializable {public string elem1; Public string elem2; Public string Elem1 {get {return elem1; } Set {elem1 = value; }} Public string Elem2 {get {return elem2; } Set {elem2 = value; }} <....  

Update: Relaxed

I was able to fix this problem through:

First of all, here is a good resource:

I've changed profile entries to:

   & Lt; / Properties & gt; & Lt; / Profile & gt;  

And then I have made MyDataClass similar to a list of MyDataClassInfo objects <:

  named place Com.xxxx.DataClasses { Serializable] Public category MyDataClass {list & lt; MyDataClassInfo & gt; MyDataClassInfo; Public MyDataClassInfo () {myDataClassInfo = New list & lt; MyDataClassInfo & gt; } Public listing & lt; MyDataClassInfo & gt; MyDataClassInfo {get; Set; }} [Serialable] public class MyDataClassInfo {public string elem1; Public string elem2; Public string Elem1 {get {return elem1; } Set {elem1 = value; }} Public string Elem2 {get {return elem2; } Set {elem2 = value; }} ....  

using the key 1) serializeAt = "binary" and 2) using a class which keeps a list in the list instead of the list .

You should never use the ArrayList class. Has been demoted as.

Instead of list & lt; MyDataClass & gt; Use . It can also solve this problem for you.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -