Remoting objects extending abstract class

  • Thread starter Thread starter sean.j.gage
  • Start date Start date
S

sean.j.gage

I was trying to abstract some properties and methods for a group of
remoting objects, but it seems that during testing I am finding that
the remoting objects are generating null reference exceptions when I
try to access these properties and methods. Below is a sample of what
I was attempting to do.

public class ParentManager : MarshalObjByRef
{
private string enabled;

protected string Enabled
{
get { return this.enabled; }
set { this.enabled = value; }
}

protected void Initialize(string value)
{
this.enabled = value;
}
}

public class SubManager : ParentManager
{
public SubManager()
{
this.Initialize("TRUE");
}

public void Test()
{
if(this.enabled.Equals("TRUE"))
{
Console.WriteLine("SubManager is enabled.");
}
}
}

When I call test I get a Null reference exception because the
initialize function has not be executed.

Cheers!
 
Hello sean,
When I call test I get a Null reference exception because the
initialize function has not be executed.

Well, where does the object come from? Are you sure you're calling the
Test method on the same instance that you initialized before? This will
depend on your activation method and where that instance/reference comes
from.


Oliver Sturm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top