2011-05-23 10 views
5

Tengo una aplicación Silverlight de contenedor/maestro. Este contenedor descarga dinámicamente xaps y llamadas a controles de usuario específicos dentro de los xaps descargados. Algunos de estos controles de usuario llaman a un servicio WCF alojado en el servidor.Llamada al servicio WCF dentro de un xap cargado dinámicamente falla

surge el siguiente error cuando los controles de usuario dentro de la XAP descargado llaman al servicio de WCF:

System.InvalidOperationException was unhandled by user code 
Message=Cannot find 'ServiceReferences.ClientConfig' in the .xap application 
package. This file is used to configure client proxies for web services, and 
allows the application to locate the services it needs. Either include this 
file in the application package, or modify your code to use a client proxy 
constructor that specifies the service address and binding explicitly. Please 
see inner exception for details. 
StackTrace: 
    at System.ServiceModel.Configuration.ServiceModelSectionGroup. 
     GetSectionGroup() 
    at System.ServiceModel.Configuration.ServiceModelSectionGroup.get_Current() 
    at System.ServiceModel.Description.ConfigLoader.LookupChannel(
     String configurationName, String contractName, Boolean wildcard) 
    at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(
     ServiceEndpoint serviceEndpoint, String configurationName) 
    at System.ServiceModel.ChannelFactory.ApplyConfiguration(
     String configurationName) 
    at System.ServiceModel.ChannelFactory.InitializeEndpoint(
     String configurationName, EndpointAddress address) 
    at System.ServiceModel.ChannelFactory`1..ctor(
     String endpointConfigurationName, EndpointAddress remoteAddress) 
    at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory() 
    at System.ServiceModel.EndpointTrait`1.CreateChannelFactory() 
    at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(
     EndpointTrait`1 endpointTrait) 
    at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef() 
    at System.ServiceModel.ClientBase`1..ctor() 
    at LoadableSilverlightApplication.MyServiceReference.MyServiceClient..ctor() 
    at LoadableSilverlightApplication.Views.MyLoadablePage.textBlock2_Loaded(
     Object sender, RoutedEventArgs e) 
    at MS.Internal.CoreInvokeHandler.InvokeEventHandler(
     Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) 
    at MS.Internal.JoltHelper.FireEvent(
     IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, 
     Int32 actualArgsTypeIndex, String eventName) 
    InnerException: System.Xml.XmlException 
     Message=Cannot find file 'ServiceReferences.ClientConfig' in the 
      application xap package. 
     LineNumber=0 
     LinePosition=0 
     StackTrace: 
      at System.Xml.XmlXapResolver.GetEntity(
       Uri absoluteUri, String role, Type ofObjectToReturn) 
      at System.Xml.XmlReaderSettings.CreateReader(
       String inputUri, XmlParserContext inputContext) 
      at System.Xml.XmlReader.Create(
       String inputUri, XmlReaderSettings settings, 
       XmlParserContext inputContext) 
      at System.ServiceModel.Configuration.ServiceModelSectionGroup. 
       GetSectionGroup() 
     InnerException: 
      ... 

La excepción me dice que el ServiceReferences.ClientConfig no es visible alguna manera ... a pesar de que esté empaquetado el xap descargado

Vi publicaciones que sugieren que el ServiceReferences.ClientConfig se empaqueta con el contenedor xap y este enfoque funciona. Sin embargo, no estoy convencido de que esta sea una solución clara.

La otra alternativa es automatizar el ServiceReferences.ClientConfig como se sugiere en http://weblogs.asp.net/manishdalal/archive/2009/02/23/silverlight-servicereferences-clientconfig-alternatives.aspx.

¿Existe una mejor solución a este problema?

Respuesta

1

WCF solo buscará en el archivo ClientConfig la aplicación principal XAP, no en ningún XAP adicional que se haya descargado. Por lo tanto, debe colocar la configuración en el XAP principal o proporcionar la configuración usted mismo, que la publicación de blog que ha vinculado muestra una forma de hacerlo.

+0

Gracias antes que nada ... ¿Qué otras maneras sugieres? ¿Hay alguna forma de usar MEF? –

Cuestiones relacionadas