Cannot find ServiceReferences.ClientConfig in .xap application package in non-shell-module

Topics: Prism v4 - Silverlight 4
Nov 23, 2011 at 8:34 AM

I'm having this issue.

separate module, referencing a wcf, throw error at runtime as "Cannot find 'ServiceReferences.ClientConfig' in the .xap application package".

if i explicitly create the service reference at the shell, it worked. as the ServiceReferences.ClientConfig will be created within.

I may create a file reference in shell to the module ServiceReferences.ClientConfig.

but we will gonna have many modules going to call diff web service, then how to add file references to all other modules in shell where they all using same name "ServiceReferences.ClientConfig"?

is there a workaround this, or i missing something?

Nov 23, 2011 at 1:17 PM


The problem you're mentioning is a valid concern in Prism applications. A possible workaround to achieve your scenario would be to create a custom ServiceReferences.ClientConfig file in your shell, that contains the information of the bindings and endpoints for the servicesin all your modules.

For example, if you had two services (namely Service1 and Service2), consumed from different modules, your ServiceReferences.ClientConfig file in the shell project could look like this:

        <binding name="CustomBinding_Service1">
          <binaryMessageEncoding />
          <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
        <binding name="CustomBinding_Service2">
          <binaryMessageEncoding />
          <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
      <endpoint address="http://localhost:2244/Service1.svc" binding="customBinding"
          bindingConfiguration="CustomBinding_Service1" contract="MyServiceReferenceInModuleA.Service1"
          name="CustomBinding_Service1" />

      <endpoint address="http://localhost:2244/Service2.svc" binding="customBinding"
          bindingConfiguration="CustomBinding_Service2" contract="MyServiceReferenceInModuleB.Service2"
          name="CustomBinding_Service2" />

If you are going to change your service references frequently, you could create a post build event that automates this merging.

I hope you find this helpful.

Guido Leandro Maliandi