I have a silverlight 5 project in VS 2010 and would like to have its config file changed based on my configuration, pretty much like one would change database connection strings for a web app.
My ServiceReferences.ClientConfig looks like this:
<configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IWcfPortal" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="25000000" maxReceivedMessageSize="25000000" /> </basicHttpBinding> </bindings> <client> <endpoint name="WcfCslaService" address="http://localhost:22/Services/WcfSlPortal.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal" /> </client> </system.serviceModel> My ServiceReferences.MyConfig.ClientConfig file (auto added with slow cheetah via right click, add transform) looks like this:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.serviceModel> <client> <endpoint name="WcfCslaService" address="http://192.168.0.0:22/Services/WcfSlPortal.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfPortal" contract="WcfPortal.IWcfPortal" xdt:Transform="Replace" /> </client> </system.serviceModel> My problem is that instead of replacing the whole node (like it is doing in my web.config in this same solution) the transform doesn't happen. I have tried clean/rebuild, manually deleting .xap file, building one project at a time. If I look in my silverlight project\bin folder and unzip my xap file it ends up containing all the ClientConfig files, and the main config file left untouched. I also have an error in my xap file underlining the "xdt:Transform" that says "The 'http://schemas.microsoft.com/XML-Document-Transform:Transform' attribute is not declared."
If I right click on ServiceReferences.MyConfig.ClientConfig, Preview Transform it shows me exactly what it should (same service with updated IP address). The other crazy thing is that this was working previously and I have no idea what I did to break it (broke right before I went to commit to the repo). I have uninstalled and reinstalled slow cheetah, restarted etc.
Anyone know how to fix this transform to work?
Answer: 1
If all you're really trying to do is replace the address, then you might try something like this. In ServiceReferences.ClientConfig I have something like
<configuration> <system.serviceModel> <!-- ... --> <client> <endpoint name="Mine" address="http://localhost:8080/SomeService.svc" binding="basicHttpBinding" bindingConfiguration="..." contract="..."/> </client> </system.serviceModel> </configuration> And to replace the address, I use the transform
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <system.serviceModel> <client> <endpoint xdt:Locator="Match(name)" xdt:Transform="SetAttributes(address)" name="Mine" address="http://SomethingElse/Services/SomeService.svc"/> If you're trying to replace the whole node, I haven't tried that, but while a pain, you could probably remove all the attributes you don't want then add new ones.
Answer by Kit for ServiceReferences.ClientConfig plus slow cheetah not transforming
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog