Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 429949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:49:33+00:00 2026-05-12T19:49:33+00:00

i’d like to create a windows service that would be accessible via WCF from

  • 0

i’d like to create a windows service that would be accessible via WCF from a web application.
The workflow would be:

  1. Windows Service starts and would hold a default value in memory.
  2. A web app would connect the windows service via wcf and take the value and after some processing set the value back in the memory.

  3. In a while would happend the same as in point 2., and so on,so on

This value would be hold only in memory.

The point is I dont know where put the variable that would be hold in the memory of the windows service.There is a Service class wich is instancied in a Program class wich is static class. So whats the best place to put a variable that would be hold in the memory as long as the service is running ?

And second question,is it correct to reference the exe of the windows service in a DLL ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:49:33+00:00Added an answer on May 12, 2026 at 7:49 pm

    There is a service class for every windows service that also contains the start and stop methods. However, for your service, I’d simply create a singleton class that is accessed from the class that handles the WCF client requests.

    There’s no need to reference the exe of the service (and I strongly recommend you not to do that), as when you’re using WCF you’ll insert a service reference into your client project and just need two methods to get and set the data.

    I suggest: Design your operation and data contracts for the service and then create the service reference within your client project. That’ll make things clear.

    If you don’t know what I’m talking about, I recommend googleing for WCF samples.

    EDIT
    You write in the comment that you created a service class with a private field. I suppose you didn’t actually do what I suggested 🙂 I said: Create a singleton class that is accessed by the class that handles the get/set requests.

    public class ValueHolder
    {
        private static ValueHolder m_singleton = null;
        private int m_someValue;
    
        private ValueHolder()
        {
            m_someValue = 0;
        }
    
        public static ValueHolder Instance
        {
            get
            {
                if (m_singleton = null)
                    m_singleton = new ValueHolder();
                return m_singleton;
            }
        }
    
        public int SomeValue
        {
            get { return m_someValue; }
            set { m_someValue = value; }
        }
    }
    

    So now you have a window service class that you use to host a WCF service. The WCF service contains methods to get/set the value from ValueHolder.Instance.SomeValue. These methods are exposed to the client using the data contract.

    Start your service and add a service reference to the client using the respective option in Visual Studio (not a reference to the DLL, but a service reference!!). The client now accesses the get/set methods of the service.

    Job done, where’s my money? 😀

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.