我有一个容器/主Silverlight应用程序。该容器会动态下载xaps并呼叫下载的xaps中的特定用户控件。 其中一些用户控件向服务器托管的WCF服务发出呼叫。在动态加载的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一起打包并且此方法有效。但我不相信这是一个很好的解决方案。
另一种替代方法是按照http://weblogs.asp.net/manishdalal/archive/2009/02/23/silverlight-servicereferences-clientconfig-alternatives.aspx中的建议自动化ServiceReferences.ClientConfig
。
是否有更好的解决方案来解决这个问题?
首先感谢..你有什么建议,有没有办法使用MEF – 2011-05-23 21:35:41