【问题标题】:How to debug WCF dataservice如何调试 WCF 数据服务
【发布时间】:2013-09-03 11:25:26
【问题描述】:

我为我的 windowsphone 应用程序编写了一个数据服务,我正在尝试保存对此数据服务的更改。为此,我致电BeginSaveChanges

    Context.AddToMeasurements(temp);
    Context.BeginSaveChanges(SaveChangesOptions.Batch, SaveChangesComplete, Context);

该函数的回调在调用EndSaveChanges时返回错误。

private void SaveChangesComplete(IAsyncResult result)
{
    // use a dispatcher to make sure the async void 
    // returns on the right tread.
    Deployment.Current.Dispatcher.BeginInvoke(() =>
    {

        DataServiceResponse WriteOperationResponse = null;

        Context = result.AsyncState as MeasurementEntities;

        try
        {
             WriteOperationResponse = Context.EndSaveChanges(result);
             Debug.WriteLine("Batch State:");
             Debug.WriteLine(WriteOperationResponse.BatchStatusCode);
        }
        catch (DataServiceRequestException ex)
        {

            Debug.WriteLine(ex.Message);
        }
        catch (InvalidOperationException ex)
        {
            Debug.WriteLine(ex.Message);
        }

    });        
}

endsavechanges 返回的错误:

An exception of type 'System.Data.Services.Client.DataServiceClientException' occurred in Microsoft.Data.Services.Client.WP80.DLL and wasn't handled before a managed/native boundary
An exception of type 'System.Data.Services.Client.DataServiceRequestException' occurred in Microsoft.Data.Services.Client.WP80.DLL and wasn't handled before a managed/native boundary
A first chance exception of type 'System.Data.Services.Client.DataServiceRequestException' occurred in Microsoft.Data.Services.Client.WP80.DLL
An exception of type 'System.Data.Services.Client.DataServiceRequestException' occurred in Microsoft.Data.Services.Client.WP80.DLL and wasn't handled before a managed/native boundary
An error occurred while processing this request.

我想查看有关这些错误的更多详细信息,或者如果有人知道它们的意思,我也会很感激,但是我如何在 Visual Studio 中完成(有关数据服务的更多详细信息)?

ps,我已经添加了:

config.UseVerboseErrors = true;

[ServiceBehavior(IncludeExceptionDetailInFaults = true)]

到我的数据服务。

请帮忙:)

编辑:


当我删除 Try 构造并执行 EndSaveChanges 方法时。我可以阅读innerExeptions,即:

当 IDENTITY_INSERT 设置为 OFF 时,无法为表“Measurement”中的标识列插入显式值。

你知道这是什么意思吗?

【问题讨论】:

  • 您可以将调试器附加到 w3wp.exe 以调试 wcf 服务
  • 是否有相关指南?哦,顺便说一句,数据服务与 Visual Studio 不在同一个桌面上运行。
  • 那怎么调试呢?
  • 我现在不能,这就是我问这个问题的原因。应该可以将数据服务移动到本地数据服务。稍后再看看。但是现在,当我尝试结束SaveChanges 时,Visual Studio 会向我抛出一些错误消息,我不知道该去哪里找。
  • 好的,我还有一点,我更新了我的答案。

标签: c# windows-phone-8 dataservice


【解决方案1】:

当 IDENTITY_INSERT 设置为 OFF 时,无法为表“Measurement”中的标识列插入显式值。

这意味着您没有将任何值传递给Measurement 列,它是数据库中的必填字段。您需要将值传递给它。

【讨论】:

  • 但这正是我想要的。我想在不指定主键的情况下插入测量值。我将数据库设置为增量和种子。也就是说没有指定measurmentid值,它会自动插入到表格的底部。那么有没有办法做到这一点?
  • 好吧,我想我解决了。我已将我的数据库端设置为自动增量和主键。我没有将此更改提交给 wcf 数据服务。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-16
  • 1970-01-01
  • 1970-01-01
  • 2013-11-11
  • 1970-01-01
相关资源
最近更新 更多