【发布时间】:2011-06-01 15:05:17
【问题描述】:
问题:
我在 Silverlight 应用程序上有一个带有参考 (.net 3.5) 的 WCF 测试服务,当我创建实例时
ServiceReference1.Service1Client client = new Service1Client();
我有以下错误:
“给定的键不在字典中。”
服务是正确的,在 web.config 我有这样的东西
<client>
<endpoint address="http://localhost:49955/Service1.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1" name="WSHttpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
在非 silverlight 应用程序中,参考工作就像一个 sharm....有一些解决它的想法吗?
PS:该服务是默认服务:
[ServiceContract]
public interface IService1
{
[OperationContract]
void DoWork();
}
public class Service1 : IService1
{
public void DoWork()
{
}
}
更多信息
{System.Collections.Generic.KeyNotFoundException:给定的键不在字典中。
在 System.ThrowHelper.ThrowKeyNotFoundException()
在 System.Collections.Generic.Dictionary2.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.ChannelFactory1..ctor(字符串端点配置名称,端点地址远程地址)
在 System.ServiceModel.EndpointTrait1.CreateSimplexFactory()
at System.ServiceModel.EndpointTrait1.CreateChannelFactory()
在 System.ServiceModel.ClientBase1.CreateChannelFactoryRef(EndpointTrait1 端点特征)
在 System.ServiceModel.ClientBase1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase1..ctor()
在 SilverlightApplication2.ServiceReference1.Service1Client..ctor()
在 SilverlightApplication2.MainPage.MainPage_Loaded(对象发送者,RoutedEventArgs e)
在 MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex,委托 handlerDelegate,对象发送者,对象参数)
在 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)}
【问题讨论】:
-
你能显示完整的堆栈跟踪吗?或者更多 .config 信息?
标签: silverlight wcf service