Hi People,
I've got a project using remoting and an ado.net dataset. As follows:
A service:
namespace myService
{
public partial class ScheduleService : ServiceBase
A class library:
namespace RemotingObject
{
public class ScheduleObject : MarshalByRefObject
A console application:
namespace TinyConsole
{
public class ScheduleClient
The service runs a routine "Init()" using remoting in the class library, which fills a DataSet with the contents of an XML file.
I have a routine addProcess in the class library which when passed a bunch of parameters creates a new row in a DataSet as follows:
public bool addProcess(string name, string exe, string schedule, string repeat, int interval)
{
if ((name != "") && (exe != "") && (schedule != ""))
{
DataRow newProcess = ds.Tables["task"].NewRow()
;
newProcess["name"] = name;
newProcess["exe"] = exe;
newProcess["schedule"] = schedule;
newProcess["repeat"] = repeat;
newProcess["interval"] = interval;
ds.Tables["task"].Rows.Add
(newProces
s);
StreamWriter sWrite = new StreamWriter(strCfgFile);
XmlTextWriter xWrite = new XmlTextWriter(sWrite);
ds.WriteXml(xWrite, XmlWriteMode.WriteSchema);
xWrite.Close();
return true;
}
else
{
return false;
}
}
When I call this from my within the class library it runs fine, however if if I try to run it from the console application as follows:
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterCh
annel(chan
, true);
RemotingObject.ScheduleObj
ect obj = (RemotingObject.ScheduleOb
ject)Activ
ator.GetOb
ject(typeo
f(Remoting
Object.Sch
eduleObjec
t), "tcp://localhost:1337/mySe
rvice");
bool res = obj.addProcess(strName, strExe, strSchedule, strRepeat, intInterval);
I get the following error:
"Object reference not set to an instance of an object"
However I can call other routines fine, e.g I have one that tells me the number of items in the dataset as follows that works ok:
numberOfObjects = obj.GetNumberOfObjects();
If I do addProcess(strName, strExe, strSchedule, strRepeat, intInterval); from within the calss library itsself it works fine.
Can anyone see what I'm doing wrong here?
Start Free Trial