locked
Access windows service from Windows store app? RRS feed

  • Question

  • Is it possible to communicate with a local windows service on the tablet from a windows store app? If no, I have another approach I'd like to have som input about. The idea is as follow:

    1) I create a windows service that listens to file changes in a specific folder using FileSystemWhatcher.

    2) My app writes an config file into that directory.

    3) The windows service kicks in when it notified the config file has been updated, connect to a local stored Microsoft Access database (Reading data from this database is what I'd like to do in the first place) and save the response as a xml file in the same directory.

    4) My app reads the xml.

    Only problem is how to wait for the windows service to write the xml before reading it from my app.

    Is this a bad approach? I really need to read data from the Microsoft Access database and no, it cannot be replaced using local storage nor can I be using web service calls.

    Wednesday, October 10, 2012 10:00 AM

Answers

  • I finally nailed it. :) I host my wcf in a windows service and bind using NetTcpBinding instead of BasicHttpBinding. Also I needed to remove loopback restrictions, CheckNetIsolation.exe helped me with that. Yes, Im pretty aware this should not be used in a production environment but I don't have much of a choice, do I?


    • Marked as answer by kolback Tuesday, October 16, 2012 2:19 PM
    • Edited by kolback Tuesday, October 16, 2012 2:23 PM
    Tuesday, October 16, 2012 2:19 PM

All replies

  • hey, I've never tried it on metro apps, but what might be a solution is to host a WCF service on your windows service and open a Duplex channel (or even a normal channel would work if your application needs certain values from the access database) with the metro app. And there it is your communication between the windows service.

    Let me know how it works out...


    Can Bilgin
    Blog CompuSight

    Wednesday, October 10, 2012 11:38 AM
  • Thanks for reply. I found this article about hosting a wcf service in a windows service:

    http://msdn.microsoft.com/en-us/library/ms733069.aspx

    It works on my developer machine (needed to change wsHttpBinding to basicHttpBinding in the service app.config):

     
    EndpointAddress endpointAdress = new EndpointAddress("http://localhost:8000/ServiceModelSamples/service");
    BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
    
    var calc = new ServiceReferenceTest.CalculatorClient(binding, endpointAdress);
    var answer = await calc.AddAsync(1, 2);

    But when installing this on my tablet nothing happens (times out I think). Installing the service was no problem, it's running ok on the tablet. Maybe BasicHttpBinding has something to do with it?



    • Edited by kolback Thursday, October 11, 2012 8:13 AM
    Thursday, October 11, 2012 8:12 AM
  • I would make sure the firewall is not blocking port 8000 and the Private Networks capability is on...

    Can Bilgin
    Blog CompuSight

    Thursday, October 11, 2012 8:28 AM
  • What is Private Network capability, where do I configure that? No blocking in my firewall.

    Thursday, October 11, 2012 12:22 PM
  • I finally nailed it. :) I host my wcf in a windows service and bind using NetTcpBinding instead of BasicHttpBinding. Also I needed to remove loopback restrictions, CheckNetIsolation.exe helped me with that. Yes, Im pretty aware this should not be used in a production environment but I don't have much of a choice, do I?


    • Marked as answer by kolback Tuesday, October 16, 2012 2:19 PM
    • Edited by kolback Tuesday, October 16, 2012 2:23 PM
    Tuesday, October 16, 2012 2:19 PM