Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8358719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:53:30+00:00 2026-06-09T10:53:30+00:00

I have 2 classes that derive from a generic base class. [Serializable()] [XmlInclude(typeof(User))] [XmlInclude(typeof(File))]

  • 0

I have 2 classes that derive from a generic base class.

[Serializable()]
[XmlInclude(typeof(User))]
[XmlInclude(typeof(File))]
public class BaseEntity<T>
{
    private long id;

    [XmlAttribute(AttributeName = "id")]
    public virtual long ID
    {
        get { return this.id; }
        set { this.id = value; }
    }
}

[Serializable()]
public class User : BaseEntity<User>
{
    private string userName;
    private string sharedDirectory;
    private bool connected;

    [XmlAttribute(AttributeName = "UserName")]
    public virtual string UserName 
    {
        get { return this.userName; }
        set { this.userName = value; } 
    }

    [XmlAttribute(AttributeName = "SharedDirectory")]
    public virtual string SharedDirectory
    {
        get { return this.sharedDirectory; }
        set { this.sharedDirectory = value; }
    }

    [XmlAttribute(AttributeName = "IsConnected")]
    public virtual bool IsConnected
    {
        get { return this.connected; }
        set { this.connected = value; }
    }
}

[Serializable()]
public class File : BaseEntity<File>
{
    private string name;
    private User user;

    [XmlAttribute(AttributeName = "Name")]
    public virtual string Name
    {
        get { return this.name; }
        set { this.name = value; }
    }

    [XmlElement(ElementName = "User", Type = typeof(User))]
    public virtual User User
    {
        get { return this.user; }
        set { this.user = value; }
    }
}

I have a web service (not WCF service) that return a List of Files (List). When i call the service, the method is preformed but the serializing process fails. This is the Exception I get:

System.Web.Services.Protocols.SoapException: Server was unable to process request. —> System.InvalidOperationException: There was an error generating the XML document. —> System.InvalidOperationException: The type Castle.Proxies.UserProxy was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.\n at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write4_User(String n, String ns, User o, Boolean isNullable, Boolean needType)\n at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write6_File(String n, String ns, File o, Boolean isNullable, Boolean needType)\n at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write7_GetFilesByNameResponse(Object[] p)\n at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer1.Serialize(Object objectToSerialize, XmlSerializationWriter writer)\n at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)\n — End of inner exception stack trace —\n at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)\n at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)\n at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)\n at System.Web.Services.Protocols.WebServiceHandler.Invoke()\n — End of inner exception stack trace —

Any one knows why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:53:31+00:00Added an answer on June 9, 2026 at 10:53 am

    Its because that i used lazy=true and when i serialized my objects, the serializer tried to serialize the Proxy object which is NOT allowed. when i changed the mapping to lazy=false it worked!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class and several concrete classes that derive from it. Lets
I have a base class DockedToolWindow : Form, and many classes that derive from
I have multiple classes that all derive from a base class, now some of
I have a class Derived that inherits directly from two base classes, Base1 and
I have two classes that are derived from an abstract generic class, which is
I have two Parser classes that inherit from a base class, BaseParser. I want
I have some functionality that I need in all my classes which derive from
If I have a class called A and I have two classes that derive
I have the following generic classes: class Base<T> where T : ... { ...
I am using a hierarchy of generic collection classes that derive from an abstract

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.