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

  • SEARCH
  • Home
  • 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 7953493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:10:18+00:00 2026-06-04T03:10:18+00:00

I have a windows service that I have been writing in Vb.Net. As part

  • 0

I have a windows service that I have been writing in Vb.Net. As part of this service it calls a class that has a long running Process.

I can execute commands to this process when I want to via the ServerCommands() class within the service, however I want to call these remotely. Possibly from a website or click once WPF application.

For this I have used a simple Tcp.Ip WCF example, and have verified it as working correctly.

This called OnStart()

Private _serverCommands As ServerCommands

Protected Overrides Sub OnStart(ByVal args() As String)
    ' Add code here to start your service. This method should set things
    ' in motion so your service can do its work.

    Debugger.Launch()

    ' Action a new implementaion of the WCF Service on localhost
    _host.AddServiceEndpoint(GetType(ICommunicationService), New NetTcpBinding(), String.Format("net.tcp://127.0.0.1:{0}", AppSettings.TcpServicePort))
    _host.Open()

    ' Start the server command
    _serverCommands = New ServerCommands()
    _serverCommands.StartServer()

End Sub

However… when I’m calling the service through WCF its starting a new instance of the ServerCommands() Class rather than attaching to the already running thread.

The following call

Public Function DoWork() As String Implements ICommunicationService.DoWork
    Dim command As String = "say hello world"

    Dim service As IMinecraftService = New MinecraftService()
    service.ExecuteServerSideCommand(command)

    Return "Command Executed"
End Function

Implements this on the main service.

Public Sub ExecuteServerSideCommand(command As String) Implements IMinecraftService.ExecuteServerSideCommand
    If (_serverCommands IsNot Nothing) Then
        _serverCommands.SendCommand(command)
    End If
End Sub

It appears that in debug _serverCommands is Nothing when it should be running.

How might I go about ensuring any command I execute through WCF communicates with the running instance instead of creating a new ServerCommand() instance??

I haven’t tried WCF before, so I might be hitting a dead end… however I’m sure its possible.

Thanks in advance.

  • 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-06-04T03:10:18+00:00Added an answer on June 4, 2026 at 3:10 am

    I found that I was calling a new instance of the MinecraftService each time I sent a command via WCF.

    As Jeff rightly said, I was not making the object shared, I was only accessing a new instance of this class.

    I changed it from

    From

    MyMainClass

        Private _serverCommands As ServerCommands
    

    My WcfService

        Dim command As String = "say hello world"
        MinecraftService.ServerCommands.SendCommand(command)
    

    To

    MyMainClass

        Public Shared ServerCommands As ServerCommands
    

    My WcfService

        MinecraftService.ServerCommands.SendCommand(command)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows service that has been scheduled using Quartz.NET . I have
I have a windows service that has been running. I have created a new
I have a Windows Service that I am in the process of writing. I
I have modified a working Windows service that had always been starting beforehand. After
I have a windows service that has it's name set by an app.config. I
I'm writing a windows service that needs to sleep for long periods of time
I have been trying to figure out quickly about writing a windows media service
I have a .NET windows service that is calling cdb.exe to analyze crash dumps.
I have a windows service that is heavily multithreaded. Each thread calls various methods
We have taken over some .NET 1.1 Windows Service code that spawns threads to

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.