Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. windows service

windows service

Scheduled Pinned Locked Moved C#
questioncsharpwcfdata-structures
14 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arkiboys
    wrote on last edited by
    #1

    Hello, I am populating a queue inside a windows service. The windows service is now installed and started on my machine. I can see in the eventlog that the queue is indeed populated i.e. enqueue and Dequeue... In the windows service, there is a simple method i.e. getQueueData which should return what is inside the queue. While the windowsservice is running, I start a wcf project which has a reference to the getQueueData method inside the windowsservice. Question: Should the wcf return the queue as it is showing inside the eventlog? I mean, while I see the queue being populated, the at the same time when I run the wcf, then should the wcf return the number of items in the queue? I ask because the wcf only seems to think there is always zero items in the queue whilst I see the eventlog and queue has data in it. Have I done everything correctly? Thanks

    P M 2 Replies Last reply
    0
    • A arkiboys

      Hello, I am populating a queue inside a windows service. The windows service is now installed and started on my machine. I can see in the eventlog that the queue is indeed populated i.e. enqueue and Dequeue... In the windows service, there is a simple method i.e. getQueueData which should return what is inside the queue. While the windowsservice is running, I start a wcf project which has a reference to the getQueueData method inside the windowsservice. Question: Should the wcf return the queue as it is showing inside the eventlog? I mean, while I see the queue being populated, the at the same time when I run the wcf, then should the wcf return the number of items in the queue? I ask because the wcf only seems to think there is always zero items in the queue whilst I see the eventlog and queue has data in it. Have I done everything correctly? Thanks

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      arkiboys wrote:

      Have I done everything correctly?

      Obviously not. If your queue has data in it, and you can't see it then you haven't done everything correctly. Without seeing your code, I'm going to take a flier as a guess - your queue is not a singleton inside the windows service, and the WCF functionality is seeing a different instance. As I say though, we can't do anymore to diagnose the issue because we have no idea what your code is. What you could do, is attach your debugger to the running instance of the service and actually step through the code and see what's going on. That would be my choice.

      I'm not a stalker, I just know things. Oh by the way, you're out of milk.

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Onyx

      A 1 Reply Last reply
      0
      • A arkiboys

        Hello, I am populating a queue inside a windows service. The windows service is now installed and started on my machine. I can see in the eventlog that the queue is indeed populated i.e. enqueue and Dequeue... In the windows service, there is a simple method i.e. getQueueData which should return what is inside the queue. While the windowsservice is running, I start a wcf project which has a reference to the getQueueData method inside the windowsservice. Question: Should the wcf return the queue as it is showing inside the eventlog? I mean, while I see the queue being populated, the at the same time when I run the wcf, then should the wcf return the number of items in the queue? I ask because the wcf only seems to think there is always zero items in the queue whilst I see the eventlog and queue has data in it. Have I done everything correctly? Thanks

        M Offline
        M Offline
        Mirko1980
        wrote on last edited by
        #3

        Is the WCF service hosted by your Windows service? Or is a different executable? If the second, obviously the WCF service sees an empty queue, because it references a different object from the one used by the Windows service.

        A 1 Reply Last reply
        0
        • P Pete OHanlon

          arkiboys wrote:

          Have I done everything correctly?

          Obviously not. If your queue has data in it, and you can't see it then you haven't done everything correctly. Without seeing your code, I'm going to take a flier as a guess - your queue is not a singleton inside the windows service, and the WCF functionality is seeing a different instance. As I say though, we can't do anymore to diagnose the issue because we have no idea what your code is. What you could do, is attach your debugger to the running instance of the service and actually step through the code and see what's going on. That would be my choice.

          I'm not a stalker, I just know things. Oh by the way, you're out of milk.

          Forgive your enemies - it messes with their heads

          My blog | My articles | MoXAML PowerToys | Onyx

          A Offline
          A Offline
          arkiboys
          wrote on last edited by
          #4

          Hi, Do you mean the following ? 1- start the windows service in the services list 2- in th ewindows service project, debug, attach to process, select the windows service from the list. If thi sis what you mean, then i do not see the windows service that I started in the list of the attach to process window. Thanks

          1 Reply Last reply
          0
          • M Mirko1980

            Is the WCF service hosted by your Windows service? Or is a different executable? If the second, obviously the WCF service sees an empty queue, because it references a different object from the one used by the Windows service.

            A Offline
            A Offline
            arkiboys
            wrote on last edited by
            #5

            Yes, the wcf is separate to windows service.

            M 1 Reply Last reply
            0
            • A arkiboys

              Yes, the wcf is separate to windows service.

              M Offline
              M Offline
              Mirko1980
              wrote on last edited by
              #6

              Then, as I said, the queue you use in the WCF service is different from the one populated in the Windows service. The WCF service must be hosted by the Windows service and reference the same instance of the queue. See here for hosting WCF services in custom applications.

              A 1 Reply Last reply
              0
              • M Mirko1980

                Then, as I said, the queue you use in the WCF service is different from the one populated in the Windows service. The WCF service must be hosted by the Windows service and reference the same instance of the queue. See here for hosting WCF services in custom applications.

                A Offline
                A Offline
                arkiboys
                wrote on last edited by
                #7

                I see what you mean. To make me understand better I would like to ask: 1- can my issue be solved if silverlight page accesses the method which is inside the windows service project? I think the answer is No and even if it did I still face the same issue because it will be lokking at a different instance to the one with the queue in it. I guess the only way to get around this is as you said to host the wcf inside the windows service project which has the queue in it being build. Am I right please? Thanks

                M 1 Reply Last reply
                0
                • A arkiboys

                  I see what you mean. To make me understand better I would like to ask: 1- can my issue be solved if silverlight page accesses the method which is inside the windows service project? I think the answer is No and even if it did I still face the same issue because it will be lokking at a different instance to the one with the queue in it. I guess the only way to get around this is as you said to host the wcf inside the windows service project which has the queue in it being build. Am I right please? Thanks

                  M Offline
                  M Offline
                  Mirko1980
                  wrote on last edited by
                  #8

                  Yes, you are right.

                  A 2 Replies Last reply
                  0
                  • M Mirko1980

                    Yes, you are right.

                    A Offline
                    A Offline
                    arkiboys
                    wrote on last edited by
                    #9

                    Many thanks

                    1 Reply Last reply
                    0
                    • M Mirko1980

                      Yes, you are right.

                      A Offline
                      A Offline
                      arkiboys
                      wrote on last edited by
                      #10

                      I have now developed a simple console app based on the example:

                      M 1 Reply Last reply
                      0
                      • A arkiboys

                        I have now developed a simple console app based on the example:

                        M Offline
                        M Offline
                        Mirko1980
                        wrote on last edited by
                        #11

                        Now you have a Windows service (that is actually a console application) that manages your queue, and a console application that exposes a WCF service. What you have to do is to put the two things together: include the code of the new console app into the code of your Window Service and make sure that both reference the same queue instance. Then, when you start the Windows service, it will also expose the WCF service that you can call from Silverlight.

                        A 1 Reply Last reply
                        0
                        • M Mirko1980

                          Now you have a Windows service (that is actually a console application) that manages your queue, and a console application that exposes a WCF service. What you have to do is to put the two things together: include the code of the new console app into the code of your Window Service and make sure that both reference the same queue instance. Then, when you start the Windows service, it will also expose the WCF service that you can call from Silverlight.

                          A Offline
                          A Offline
                          arkiboys
                          wrote on last edited by
                          #12

                          Hi, I don't think I have "and a console application that exposes a WCF service" I only have a windows service.

                          M 1 Reply Last reply
                          0
                          • A arkiboys

                            Hi, I don't think I have "and a console application that exposes a WCF service" I only have a windows service.

                            M Offline
                            M Offline
                            Mirko1980
                            wrote on last edited by
                            #13

                            You said "I have now developed a simple console app based on the example". So I thought that you had put the WCF service on a separate Console Application. If you have already put the WCF service into the Windows service, you should be able to browse it from IE on the url you specified when coding it (the example I gave you uses http://localhost:8080/hello). You have only to add a service reference to your WCF service in the Silverlight application so that it can communicate with the Windows service.

                            A 1 Reply Last reply
                            0
                            • M Mirko1980

                              You said "I have now developed a simple console app based on the example". So I thought that you had put the WCF service on a separate Console Application. If you have already put the WCF service into the Windows service, you should be able to browse it from IE on the url you specified when coding it (the example I gave you uses http://localhost:8080/hello). You have only to add a service reference to your WCF service in the Silverlight application so that it can communicate with the Windows service.

                              A Offline
                              A Offline
                              arkiboys
                              wrote on last edited by
                              #14

                              Thank you

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups