我收到以下错误:“字典中没有给定的密钥。”
代码只是尝试创建代理客户端连接:
FileService.FileServiceClient svc = new CCS.FileService.FileServiceClient();
堆栈追踪:
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.ServiceModel.Configuration.ServiceModelSectionGroup.get_Client()
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.ChannelFactory`1..ctor(String endpointConfigurationName)
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 CCS.FileService.FileServiceClient..ctor()
at CCS.MainPage..ctor()
at CCS.App.Application_Startup(Object sender, StartupEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
我有一个Silverlight 3应用程序,我正在Web应用程序上添加WCF服务。有人知道解决这个问题的方法吗?看起来它很难获得绑定信息。
答案 0 :(得分:2)
听起来像this is an issue with the Visual Studio加载错误的Silverlight 2文件而不是Silverlight 3文件:
要解决此问题,请卸载Silverlight 2 SDK,更新服务参考,然后重建Silverlight应用程序。
如果您希望Silverlight 2和Silverlight 3应用程序都可以使用您的服务,则可以将绑定更改回basicHttpBinding。为此,请编辑包含该服务的Web项目的web.config文件。然后更新服务引用并重建Silverlight应用程序。