【问题标题】:Calling WCF in SilverLight compoment在 SilverLight 组件中调用 WCF
【发布时间】:2010-10-03 02:46:02
【问题描述】:

下面的代码抛出了一个异常,我不知道出了什么问题,有人能解释一下吗?

RestAPIDataContext ctx = GetContext();            
var songsQuery = (from item in ctx.Songs
                                  where item.Artist.Title == "George Michael"
                                  select item) as DataServiceQuery<SongsItem>;
                    songsQuery.BeginExecute(
                        (IAsyncResult asyncResult) => Dispatcher.BeginInvoke(() =>
                                                                                 {
                                                                                     songsList.ItemsSource = songsQuery.EndExecute(asyncResult);
                                                                                 }), songsQuery
                        );
private static RestAPIDataContext GetContext()
        {
            RestAPIDataContext ctx =
              new RestAPIDataContext(
              new Uri("http://win-oirj50igics/restapi/_vti_bin/ListData.svc"));
            return ctx;
        }

System.Data.Services.Client.DataServiceQueryException:处理此请求时发生错误。 ---> System.InvalidOperationException:保存更改时出错。有关详细信息,请参阅内部异常。 ---> System.Data.Services.Client.DataServiceClientException: 请求版本“1.0”对于响应来说太低了。支持的最低版本是“2.0”。 --- 内部异常堆栈跟踪结束 --- 在 System.Data.Services.Client.BaseAsyncResult.EndExecute[T](对象源,字符串方法,IAsyncResult asyncResult) 在 System.Data.Services.Client.QueryAsyncResult.EndExecute[TElement](对象源,IAsyncResult asyncResult) --- 内部异常堆栈跟踪结束 --- 在 System.Data.Services.Client.QueryAsyncResult.EndExecute[TElement](对象源,IAsyncResult asyncResult) 在 System.Data.Services.Client.DataServiceQuery`1.EndExecute(IAsyncResult asyncResult) 在 SLRest.MainPage.c_DisplayClass3.c_DisplayClass5.b__1()

【问题讨论】:

    标签: silverlight-3.0 wcf


    【解决方案1】:

    从调用堆栈看来,您正在使用 ADO.Net 数据服务框架。您可以尝试使用此link 对其进行更新,也可以将调用者应用程序的目标框架更改为 4.0。

    查看link了解详情

    【讨论】:

    • 谢谢队友,您的解决方案有效。但我的不是控制台应用程序,它是 SilverLight 应用程序。所以我将 SilverLight 应用程序版本从 3.0 更改为 4.0,现在可以正常工作了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 2010-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多