Question

Ok so I know I am very very new to .NET remoting and I have a question as far as best practice goes. First, I already have an in-house application that I have built and have dll's that I reference that handle all of the data for me. I want the Server version of my application to be able to utilize all of those classes and their methods and be able to pass those custom objects back and forth.

My question is, should I, apply [Serializable] to all of my classes that I want to pass back and forth and then create special classes that specifically use my methods to Get, AddOrUpdate, Delete, etc?

Right now, I have Get, AddOrUpdate, and Delete methods in all of my classes that communicate back and forth with my database. I have already learned that I can't MarshalByRefObject & [Serializable] to all of those classes or I will run into issues. So, thats why I am thinking I need to create separate classes that do "Management" (ex. Get, AddOrUpdate, Delete) as opposed to having Property definitions as well as Method calls.

An example of what I am thinking needs to be done.

[Serializable]
    public class Users {
        #region Properties...
        private int _userID;
        private string _displayName;
        private string _userName;
        private string _firstName;
        private string _lastName;
        private string _LogOnPassword;
        private List<Users> _Associates = new List<Users>();
        private AuthenticationLevel _authorizationLevel;
        private string _userSettingsXML;
        private string _active;
        private string _signature;
        private int _PhoneExtension;
        private int _Index;
        private List<UserAssignedRoles> _Roles = new List<UserAssignedRoles>();

Then to actually create a list I would have a separate class called something like UserManagement.

public class UserManagement : MarshalByRefObject { 
    public List<Users> GetUsers() { 

    }
}

Any advice is greatly appreciated!

Was it helpful?

Solution

Remoting might be a fine approach, but since you didn't give a lot of context as to why you are remoting, let me offer an additional suggestion. You may want to consider creating Web Services for communication across architectural tiers. Windows Communication Foundation (WCF) is a mature technology that makes this pretty straight-forward for simple communication. You may also want to read about Service Oriented Architecture (SOA), perhaps starting with the four SOA tenets.

You should not have any trouble reusing your current classes with WCF. Services will just give you a little better structure, plus WCF skills are far more common than .NET Remoting skills (for the person who needs to manage this code next after you).

Good luck! -Bill

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top