【发布时间】: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