General discussion

Locked

DataSet in C# Running as Windows Service

By netsecsvc ·
My program has a Dataset that writes to a database when it receives information, it works fine. However, I want to convert the program into a Windows Service, which would mean the Dataset would have to be in the Service, and the Datagrid display GUI would have to be a seperate executable that reads the Dataset. Therein lies the problem, the Dataset within the Service cannot be read from the GUI even if it is set as Static Public. Surely this sort of thing has been done a million times, but I can't find any documentation relating to this. What methodology is used to achieve the dataset backend / GUI front end service functionality?

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by amoljpatil In reply to DataSet in C# Running as ...

Basically, to do this, service have to expose an object through remoting. Then, you can get a proxy object of the service and execute methods of that service.

Try in this manner.
Hope this will work.

Cheers,

Amol

Collapse -

by netsecsvc In reply to

Yes, some code would have helped ... this is what I came up with in the service executable:
tc=new TcpChannel(8888);
ChannelServices.RegisterChannel(tc);
RemotingConfiguration.RegisterWellKnownServiceType(typeof Log),"NSS_Syslog",WellKnownObjectMode.Singleton);
logger=(Log)Activator.GetObject(typeof Log),"tcp://localhost:8888/NSS_Syslog");
logger.Start();

Collapse -

by Tony Hopkinson In reply to DataSet in C# Running as ...

You've got to split waht the sevice does from controlling/monitoring it.
Take the gui out of the service.
ie have the gui and the service write to and read from a common store of some description.
Given you rea using a dataset, a common table / query stands out as an obvious solution.

Collapse -

by netsecsvc In reply to

Yes, some code would have helped ... this is what I came up with in the service executable:
tc=new TcpChannel(8888);
ChannelServices.RegisterChannel(tc);
RemotingConfiguration.RegisterWellKnownServiceType(typeof Log),"NSS_Syslog",WellKnownObjectMode.Singleton);
logger=(Log)Activator.GetObject(typeof Log),"tcp://localhost:8888/NSS_Syslog");
logger.Start();

Collapse -

by shri_ohm In reply to DataSet in C# Running as ...

Did you find solution? I am working with same problme. If you know solution please help me.

Thank You

Collapse -

by Tony Hopkinson In reply to DataSet in C# Running as ...

Thought I'd given it.
Write the service with no gui.
Have it do it's stuff and save the results back to a table. Have another table for control of the service.
Then write you controlling/Monitoring GUI to read write to the Tables.
So if you had a GUI to say pause the service.
The sevice reads the service_control table and checks to see if paused is true, if so does nothing. The GUI reads paused from service control and displays and gives the user the facility to set it true or false. There are other ways than a table, but you need an area common to both application and service but completely independant. Just be careful about locking.

Collapse -

by netsecsvc In reply to

Well, actually the Dataset is simply inneficient for this. I learned to use NO DATASET in the service and to use STORED PROCEDURES (i.e. execute nonquery) to add each new record directly to the database. The GUI of course is using a dataset but in order to make it efficient, it is created by a "filtered" data adapter. In other words, that data adapter uses a SQL query that selects the top 100 records or so, instead of all records.

Collapse -

by netsecsvc In reply to DataSet in C# Running as ...

This question was closed by the author

Back to Web Development Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums