• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

How to extend/modify a C# object dynamically

I'm looking for a way to allow the users of my C# .NET WinForms application to extend its business domain without having me make manual changes to the VS Project.
Here is an example:
Let's say, we have an application called "Friends List" that helps keep track of one's friends.
In this application there is an object named "Person", which has a single public property "FIrstName".
Now, let's assume that there is a second application called "List Maker" that present the user with a simple form to allow add more properties to the "Person" (i.e. "Last Name", "Address", etc...)
Once such additions are made, the "List Maker" application would, in fact, make changes to the existing "Person" class by adding the "Last Name" and "Address" public properties to it.
Then the "List Maker" application would recompile the "Friends List" project, so, the next time the user run it, the Person will have those added properties.
I think, this could be accomplished with a help of the CSharpCodeProvider class.
I'm just not sure how to do this.

  • 2
1 Solution
The way I would do is to have a parent class called person and then provide a child class which inherits from person with additional properties and do all the operations on the child class object
Have a look at the discussion here. It might be helpful:

eugene-gAuthor Commented:
Is there a way to compile a C# solution without having Visual Studio installed?
Of course that's possible. Using C# compiler from a command line. Have a look:


It's also possible to use tools like nant to "build" (compile) your solution. You may search for nant on internet. Have a look at simple example:

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now