Click here to Skip to main content
15,907,183 members
Home / Discussions / C#
   

C#

 
AnswerRe: Thumbnail control for sorting images by drag & drop Pin
Eddy Vluggen22-Apr-10 5:36
professionalEddy Vluggen22-Apr-10 5:36 
GeneralRe: Thumbnail control for sorting images by drag & drop Pin
ab-tools22-Apr-10 5:44
ab-tools22-Apr-10 5:44 
GeneralRe: Thumbnail control for sorting images by drag & drop Pin
Eddy Vluggen22-Apr-10 6:01
professionalEddy Vluggen22-Apr-10 6:01 
GeneralRe: Thumbnail control for sorting images by drag & drop Pin
ab-tools22-Apr-10 6:11
ab-tools22-Apr-10 6:11 
QuestionRead IP address of all website currently visted Pin
makdu22-Apr-10 2:15
makdu22-Apr-10 2:15 
QuestionEnum Member Pin
DIPAK@EMSYS22-Apr-10 0:59
DIPAK@EMSYS22-Apr-10 0:59 
AnswerRe: Enum Member Pin
OriginalGriff22-Apr-10 1:02
mveOriginalGriff22-Apr-10 1:02 
GeneralRe: Enum Member Pin
DIPAK@EMSYS22-Apr-10 1:10
DIPAK@EMSYS22-Apr-10 1:10 
GeneralRe: Enum Member Pin
OriginalGriff22-Apr-10 1:27
mveOriginalGriff22-Apr-10 1:27 
AnswerRe: Enum Member Pin
#realJSOP22-Apr-10 1:32
professional#realJSOP22-Apr-10 1:32 
AnswerRe: Enum Member Pin
Pete O'Hanlon22-Apr-10 2:01
mvePete O'Hanlon22-Apr-10 2:01 
GeneralRe: Enum Member Pin
DIPAK@EMSYS22-Apr-10 2:05
DIPAK@EMSYS22-Apr-10 2:05 
GeneralRe: Enum Member Pin
PIEBALDconsult22-Apr-10 4:54
mvePIEBALDconsult22-Apr-10 4:54 
AnswerRe: Enum Member Pin
PIEBALDconsult22-Apr-10 4:57
mvePIEBALDconsult22-Apr-10 4:57 
Questionsending the value of a parameter in a form to another form smart device Pin
bacem smari22-Apr-10 0:25
bacem smari22-Apr-10 0:25 
AnswerRe: sending the value of a parameter in a form to another form smart device Pin
Sandesh M Patil22-Apr-10 2:19
Sandesh M Patil22-Apr-10 2:19 
GeneralRe: sending the value of a parameter in a form to another form smart device Pin
bacem smari22-Apr-10 3:39
bacem smari22-Apr-10 3:39 
Questionstore the results of a WMI requests in a SQLite database Pin
hafsaben22-Apr-10 0:02
hafsaben22-Apr-10 0:02 
QuestionChanging the disposition of my listView.items in csharp smart device [modified] Pin
Tunisien8621-Apr-10 23:40
Tunisien8621-Apr-10 23:40 
AnswerRe: Changing the disposition of my listView.items in csharp smart device Pin
Tunisien8622-Apr-10 5:27
Tunisien8622-Apr-10 5:27 
QuestionCreating Database and assigning DataSet shema to the Data Source Pin
pandit8421-Apr-10 23:20
pandit8421-Apr-10 23:20 
AnswerRe: Creating Database and assigning DataSet shema to the Data Source Pin
Dave Kreskowiak22-Apr-10 6:21
mveDave Kreskowiak22-Apr-10 6:21 
QuestionHow to add XmlInclude attribute dynamically Pin
Anindya Chatterjee21-Apr-10 23:09
Anindya Chatterjee21-Apr-10 23:09 
I have the following classes

[XmlRoot]
public class AList
{
   public List<B> ListOfBs {get; set;}
}

public class B
{
   public string BaseProperty {get; set;}
}

public class C : B
{
    public string SomeProperty {get; set;}
}

public class Main
{
    public static void Main(string[] args)
    {
        var aList = new AList();
        aList.ListOfBs = new List<B>();
        var c = new C { BaseProperty = "Base", SomeProperty = "Some" };
        aList.ListOfBs.Add(c);

        var type = typeof (AList);
        var serializer = new XmlSerializer(type);
        TextWriter w = new StringWriter();
        serializer.Serialize(w, aList);
    }    
}


Now when I try to run the code I got an InvalidOperationException at last line saying that

The type XmlTest.C was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.

I know that adding a [XmlInclude(typeof(C))] attribute with [XmlRoot] would solve the problem. But I want to achieve it dynamically. Because in my project class C is not known prior to loading. Class C is being loaded as a plugin, so it is not possible for me to add XmlInclude attribute there.

I tried also with

TypeDescriptor.AddAttributes(typeof(AList), new[] { new XmlIncludeAttribute(c.GetType()) });


before

var type = typeof (AList);


but no use. It is still giving the same exception.

Does any one have any idea on how to achieve it?

QuestionCross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on. Pin
jkpieters21-Apr-10 22:59
jkpieters21-Apr-10 22:59 
AnswerRe: Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on. Pin
Anindya Chatterjee21-Apr-10 23:12
Anindya Chatterjee21-Apr-10 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.