积极答复者
风云的《银光志3.0》_书中第十三章的例子(13.8.1)出错请教

问题
-
MainPage.xaml.cs :
public MainPage() { InitializeComponent(); DataBind(); } //数据绑定 private void DataBind() { //添加事件 WCFService.DGServiceClient sc = new Sample.WCFService.DGServiceClient(); sc.GetUsersCompleted += new EventHandler<Sample.WCFService.GetUsersCompletedEventArgs>(sc_GetUsersCompleted); //调用GetUsers方法 sc.GetUsersAsync(); } //WCF调用完成事件 void sc_GetUsersCompleted(object sender, GetUsersCompletedEventArgs e) { //取得返回的用户数据 List<user> users = new List<user>(e.Result); //为DataGrid控件设置数据源 myDataGrid.ItemsSource = users; }
WCFService.DGServiceClient sc = new Sample.WCFService.DGServiceClient();
这里出错。
+ $exception {System.Collections.Generic.KeyNotFoundException: 给定关键字不在字典中。
位于 System.ThrowHelper.ThrowKeyNotFoundException()
位于 System.Collections.Generic.Dictionary`2.get_Item(TKey key)
位于 System.ServiceModel.Configuration.ServiceModelSectionGroup.get_Client()
位于 System.ServiceModel.Description.ConfigLoader.LookupChannel(String configurationName, String contractName, Boolean wildcard)
位于 System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
位于 System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
位于 System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
位于 System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
位于 System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName)
位于 System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
位于 System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
位于 System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
位于 System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
位于 System.ServiceModel.ClientBase`1..ctor()
位于 Sample.WCFService.DGServiceClient..ctor()
位于 Sample.MainPage.DataBind()
位于 Sample.MainPage..ctor()
位于 Sample.App.Application_Startup(Object sender, StartupEventArgs e)
位于 System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
位于 MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)} System.Exception {System.Collections.Generic.KeyNotFoundException}WebService什么的都没有问题,能出来。
等解决方案
答案
-
这一句出错: WCFService.DGServiceClient sc = new Sample.WCFService.DGServiceClient();
- 已标记为答案 天使坠Moderator 2011年7月11日 6:16
全部回复
-
这一句出错: WCFService.DGServiceClient sc = new Sample.WCFService.DGServiceClient();
- 已标记为答案 天使坠Moderator 2011年7月11日 6:16
-
你的开发工具的版本是VS2008+SL3吗?
My blog: http://blog.csdn.net/dotfun http://dotfun.cnblogs.com
My contact: QQ:372900288 E-mail:372900288@qq.com msn:sellnet007@hotmail.com
《银光志--Silverlight 3.0开发详解与最佳实践》 -
我这边刚才运行了一下,没发现问题,你是直接在VS里运行吗
My blog: http://blog.csdn.net/dotfun http://dotfun.cnblogs.com
My contact: QQ:372900288 E-mail:372900288@qq.com msn:sellnet007@hotmail.com
《银光志--Silverlight 3.0开发详解与最佳实践》 -
嗯,请你重新引用一下WCF试一下
My blog: http://blog.csdn.net/dotfun http://dotfun.cnblogs.com
My contact: QQ:372900288 E-mail:372900288@qq.com msn:sellnet007@hotmail.com
《银光志--Silverlight 3.0开发详解与最佳实践》