DbContext.SaveChanges() 上的 EF 4.1 ComException

发布于 2024-11-27 01:18:10 字数 561 浏览 6 评论 0原文

我正在使用 EF 4.1。每当执行 DbContext 操作(如 SaveChanges())期间发生错误时,我都会收到一条相当神秘的错误消息:System.Exception._ComPlusExceptionCode -532462766。显然这对于​​找出问题所在并没有多大帮助。在 EF 上下文中快速 Google 搜索 ComPlusException 没有返回任何有意义的结果。

如果我收到此错误消息的原因以及可以采取哪些措施以获得更具描述性的错误反馈,我们将不胜感激。

谢谢!!

代码:

    public void InsertTarget(Target target)
    {
        try
        {
            _tgrContext.Targets.Add(target);
            _tgrContext.SaveChanges();
        }
        catch (Exception)
        {
            throw;
        }
    }

I'm using EF 4.1. Whenever an error occurs during the execution of a DbContext operation like SaveChanges() I consistently receive a rather cryptic error message: System.Exception._ComPlusExceptionCode -532462766. Obviously this is not very helpful for finding out what went wrong. A quick Google search for ComPlusException in context with EF returned no meaningful results.

Any ideas why I receive this error message and what can be done in order to get a more descriptive error feedback would be much appreciated.

Thanks!!

Code:

    public void InsertTarget(Target target)
    {
        try
        {
            _tgrContext.Targets.Add(target);
            _tgrContext.SaveChanges();
        }
        catch (Exception)
        {
            throw;
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖 2024-12-04 01:18:10

在这里找到问题的答案:

complusexceptions in net< /a>

简而言之:在 VS 代码编辑器中单击红色错误引号时,Visual Studio 将 complusException 代码解码为实际的错误消息。我很少使用这个视觉指示器,所以我想我很容易错过它。

Found the answer to the problem here:

complusexceptions in net

In short: Visual Studio decodes the complusexception code into the actual error message on click at the red error quation mark in the VS code editor. I hardly ever use this visual indicatior, so I guess it was easy to miss for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文