Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 5th, 2006, 03:01 PM
Registered User
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing Windows service from a windows app

Hi All,

I've a desktop application, which has a local db, and a master copy of that db is on server, so we need to synch.

For synchronization we've made a separate Windows service, so that it can run separately from the application and synch. and when the application starts it should stop, so that synching of the tables dont disturb the user interface.

Now that Windows Service needs to know few things from the main application, like on the event when the user Enables his sharing in the application, I need to tell this to the service, and pass on the database credentials to it from the main application, which it can use for synching, prior to this event it'd do nothing.

   1. How can I stop the service, when the application starts?
   2. For passing info from application to Service, how do I set it?, One idea thats in my mind, is have a public method in the Service class like

public bool SetProperties(string DbLogin, string, DbPassword, string DBName)
  Properties.Settings.Default.DBLogin = DBLogin;
  Properties.Settings.Default.DbPassword= DbPassword;
  Properties.Settings.Default.DBName= DBName;

and call it on the EnableSharing event from the application, but I am confused on how to get the active instance of the Service, I can add the reference of the dll of Service, but would that give me access to the service, which is currently stopped?

   3. Is there a better way to do what I am trying to do?

Thanks for your time,

Old October 6th, 2006, 10:25 AM
Registered User
Join Date: Sep 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

Waiting for replies....

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Debug Windows App? Ron Howerton Visual Studio 2005 5 November 30th, 2007 05:20 PM
Accessing SQL Server from a Windows Service jeffgruending Pro Visual Basic 2005 3 November 21st, 2007 05:18 PM
Windows Standalone app echovue Visual Basic 2005 Basics 3 March 12th, 2007 03:27 PM
Works under App but not under Windows service floydus C# 0 February 12th, 2007 11:40 AM
Calling windows app from web service .. André G.Agayby Classic ASP Basics 1 August 1st, 2005 05:57 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.