locked
Silverlight 4 and WCF services RRS feed

  • Question

  • I need to communicate with a serial port device in a Silverlight app. Knowing that I cannot access the serial port in Silverlight, I created a WCF service that runs on the local machine. The WCF service communicates with the device. I've tested the service in a console application so I know that the service is working. Unfortunately I keep getting a SecurityException when I try to access the service from the SL app.

    More Info:

    • I have a console app that hosts the WCF service running on the local machine where the device is attached.
    • In the service root I have a CrossDomain.xml and ClientAccessPolicy.xml file which should allow the WCF calls
    • I can set a reference to the service from the SL app. This creates the proxy and the ServiceReferences.ClientConfig.
    • The address of the service is http://localhost:43258/ScaleService. I've also tried my machine name.
    • Since the call is async, I subscribe to the completed event.
    • I make the call through the proxy and get a SecurityException.

    Can I communicate with a service on the local machine?

    Any help would be appreciated.

    Thanks

    Chris Rolon 

     

     

     

    Thursday, April 22, 2010 2:52 PM

Answers

  •  I've run into this problem as well. My issue was using the browser's http stack when I needed to use Silverlight client's HTTP stack. You can set which stack your request uses like so:

    WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);

    // Call to proxy method in the same scope

    In this case any requests made to http will use the client stack. Alternatively you can use WebRequestCreator.BrowserHttp.

    Thursday, April 22, 2010 4:48 PM

All replies

  •  I've run into this problem as well. My issue was using the browser's http stack when I needed to use Silverlight client's HTTP stack. You can set which stack your request uses like so:

    WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);

    // Call to proxy method in the same scope

    In this case any requests made to http will use the client stack. Alternatively you can use WebRequestCreator.BrowserHttp.

    Thursday, April 22, 2010 4:48 PM
  • Hi,

    Create an activeX to communicate with the serial port seems easier than a wcf service.

    If your program runs on Windows in OOB mode of course.

    ++

    Thursday, April 22, 2010 5:04 PM