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

  • Home
  • SEARCH
  • 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 6980355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:00:22+00:00 2026-05-27T18:00:22+00:00

If I have a complex object, can I inherit from it and remove or

  • 0

If I have a complex object, can I inherit from it and remove or ignore certain properties?

If you don’t care why I want to do this, feel free to just submit an answer.

If you do care, you can read this question. To summarize it, I have an object that has a single property that is not serializable, and I want to serialize the entire object. The object in question is System.Exception

To get around the problem I wanted to simply create my own JsonException object, inherit all the lovely properties of the base (System.Exception) except remove (or empty) the ugly duckling (Exception.TargetSite).

Something like:

public class MyException : Exception
{
    // Note this is not actually possible
    //      just demonstrating what I thought to do in theory
    public override System.Reflection.MethodBase TargetSite
    {
        get
        {
            return null;
        }
    }

    public MyException(string message)
        : base()
    {
    }
}

Also please keep in mind I am stuck with .NET 2.0 and really don’t want to use custom serializers (like Json.NET) if I don’t have to.

  • 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-05-27T18:00:23+00:00Added an answer on May 27, 2026 at 6:00 pm

    Did you try it without overriding the TargetSite property? I was able to do it (but not in 2.0, so I’m not sure if it will work for you like this

    public class MyException : Exception
    {
        public new System.Reflection.MethodBase TargetSite
        {
            get { return null; }
        }
    
        public MyException() : base()
        {
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complex django object, which has properties of other class types. This
I have some complex object graphs, when I want to send them down to
I have a complex JSON object that I want represent as C# class. I
I have a class that represents a pretty complex object. The objects can be
I have a complex object I'm getting back as a return value from the
I have one extremely complex json object, I'm needing to write all the properties
If i have a complex object, what is the best practice pattern to write
I have a pretty complex object graph G with an object o1 in G
What is the format for databinding to a complex object? I have a linq
I have a List of a complex type - an object with a few

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.