I’m programming my first Silverlight app and it uses a Silverlight-enabled WCF service to retrieve and send data to my server.
I created a SL application + ASP.NET MVC web page to host the SL app.
In the MVC app I create the WCF service and I consume it on the SL app. So far so good.
I deploy the project using the Web deploy and it works on my remote host but using Fiddler I realize that the remote app is using the WCF service I have on the development server (AKA localhost:port).
I changed the WCF service in VS and it now points to the remote host and if I deploy the solution, so far so good.
But you know, now my service points to a remote server and doesn’t work because I have to create the xml for crossdomain access (and fiddler says to me that is looking on domain.com/crossdomain.xml instead of domain.com/virtualdirectory/crossdomain.xml).
So my question is: How I handle this? Would be good to have my project using the local service and when I deploy, it use the remote one.
Do I have to do this manually or there is an automatic way?
Thanks.
The endpoint address is included in the
ServiceReferences.ClientConfigfile, which is then part of the files embedded in the XAP package. You have to update that file when you deploy to the live server.A workaround is to build a factory method for the client proxy class, which builds the service address dynamically from the address of the Silverlight package. Here is a guide, which contains the following code:
Using such a factory you will be able to deploy your app to any server without reconfiguration, as long as the silverlight XAP file and the service are located in the same way relative to eachother.