【问题标题】:AdxStudio CrmEntityFormView Swallowing Microsoft.Xrm.Sdk.SaveChangesExceptionAdxStudio CrmEntityFormView 吞咽 Microsoft.Xrm.Sdk.SaveChangesException
【发布时间】:2014-11-08 05:17:55
【问题描述】:

我在 AdxStudio 论坛上发布了这个并且得到了完全零响应,所以我希望你们能帮助我调试这个。

我正在使用 CrmEntityFormView 在 CRM 中创建新联系人,如下所示:

<adx:CrmDataSource ID="FormViewDataSource" runat="server" />
    <adx:CrmEntityFormView runat="server" ID="UserCreateForm" EntityName="contact" FormName="User Edit Form" DataSourceID="FormViewDataSource"
        RecommendedFieldsRequired="true" ValidationGroup="NewUser" ValidationText="* This field is required" EnableValidationSummaryLinks="false" 
        OnItemInserting="UserCreateForm_ItemInserting" OnItemInserted="UserCreateForm_ItemInserted">
        <InsertItemTemplate></InsertItemTemplate>
</adx:CrmEntityFormView>

<asp:Button ID="SubmitButton" Text='Create User' CssClass="button" ValidationGroup="NewUser" runat="server" OnClick="SubmitButton_Click" />

我正在使用 SubmitButton_Click 处理程序同时处理表单上的一些其他字段,如下所示:

 protected void SubmitButton_Click(object sender, EventArgs e)
 {
    if (!Page.IsValid)
        {
            return;
        }

    # Handle other form fields not on the FormView ...
    UserCreateForm.InsertItem();
 }

当我提交有效表单时,我的数据库中没有任何反应。所以我调试了 ItemInserted 事件,在处理程序的单行上放了一个断点

    protected void UserCreateForm_ItemInserted(object sender, CrmEntityFormViewInsertedEventArgs e)
    {
        Contact newUser = XrmContext.ContactSet.Where(c => c.ContactId == e.EntityId).FirstOrDefault();
    }

事实证明,在这种情况下,e.Exception 不是 null,而是标题中 SaveChangesException 的一个实例,消息是“处理此请求时发生错误”。和 e.ExceptionHandled == true,我猜这就是我什么都没看到的原因。

这个异常有一个InnerException,一个System.ServiceModel.FaultException&lt;Microsoft.Xrm.Sdk.OrganizationServiceFault&gt;的实例

带有始终只包含 FormView 中第一个字段的提交值的消息。我完全不知道为什么这不起作用,我不清楚如何进一步调试它并可以使用一些指针。

【问题讨论】:

    标签: dynamics-crm-2011


    【解决方案1】:

    System.ServiceModel.FaultException&lt;Microsoft.Xrm.Sdk.OrganizationServiceFault&gt; 吃掉堆栈跟踪。请参阅 this blog 作为实际记录堆栈跟踪的方法,以便能够找到发生错误的位置。

    【讨论】:

      猜你喜欢
      • 2017-01-26
      • 2016-01-21
      • 2014-07-03
      • 1970-01-01
      • 2013-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      相关资源
      最近更新 更多