You are getting NullReferenceException
on adding parameterless constructor as parameter is required for proper initialization. By not supplying it, some part of initialization is missed.
You should refactor your code to allow parameter less constructor as
private bool _initialized = false;
public MyMsgBus() {}
public Initialize(string busname) // Make this part of interface
{
myMsgBus = new List<string>();
myIpc = CreateIpcChannel(busname);
ChannelServices.RegisterChannel(myIpc);
var entry = new WellKnownServiceTypeEntry(
typeof(MxServeBus),
"MyRemoteObj.rem",
WellKnownObjectMode.Singleton);
RemotingConfiguration.RegisterWellKnownServiceType(entry);
_initialized = true;
}
In all other public methods, check for _initialized
flag and throw NotInitializedException
if flag is false.
You should use it as
IMyMsgBus lBus = (IMyMsgBus)Activator.GetObject(typeof(IMyMsgBus));
lBus.Initialize(objUri);
... do Further operation