5

コンテナー/マスター Silverlight アプリケーションがあります。このコンテナーは xap を動的にダウンロードし、ダウンロードした xap 内の特定のユーザー コントロールを呼び出します。これらのユーザー コントロールの一部は、サーバーでホストされている WCF サービスを呼び出します。

ダウンロードした xap 内のユーザー コントロールが 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:
          ...

例外はServiceReferences.ClientConfig、ダウンロードした xap 内にパッケージ化されているにもかかわらず、何らかの形で表示されないことを示しています。

ServiceReferences.ClientConfigがコンテナー xap と一緒にパッケージ化され、このアプローチが機能することを示唆する投稿を見ました。ただし、これがきちんとした解決策であるとは確信していません。

もう 1 つの方法は、 http://weblogs.asp.net/manishdalal/archive/2009/02/23/silverlight-servicereferences-clientconfig-alternatives.aspxServiceReferences.ClientConfigで提案されているように自動化することです。

この問題に対するより良い解決策はありますか?

4

1 に答える 1

1

WCF は、ダウンロードされた追加の XAP ではなく、メイン アプリケーション XAP の ClientConfig ファイルのみを検索します。そのため、構成をメインの XAP に配置するか、構成を自分で提供する必要があります。これは、リンクしたブログ投稿が 1 つの方法を示しています。

于 2011-05-23T20:47:25.147 に答える