调用外部构造函数时应用程序挂起 - 故障排除步骤?

发布于 2024-10-16 06:38:47 字数 520 浏览 2 评论 0原文

这可能是一个很遥远的事情,但我没有主意。

我有一个 VS C# 解决方案,其中包含三个项目。有一个类库项目,然后是两个依赖于该类库的应用程序项目。该类库又依赖于其他一些 DLL,包括来自 Sharpdevelop 项目的 avalonedit DLL。

其中一个应用程序正在构建并运行良好,包括使用我自己的包装 avalonedit 控件的控件。另一个应用程序无法运行,并且在我的包装控件中通过 XAML 初始化 avalonedit 控件时似乎失败了。

问题是我在调试输出中根本看不到任何错误,我看到的只是 dll 加载消息,然后什么也没有。如果我进入控件的构造函数,则该步骤永远不会完成。调试器表示应用程序正在运行,但当 XAML 端构建底层编辑控件时,它显然在 avalonedit dll 中的某个位置旋转。

我必须假设这两个项目之间的环境差异存在一些问题,但我对如何继续追踪问题感到有点困惑。我是否必须以某种方式安排事情,以便我可以中断 avalonedit 源?

编辑:如果我暂停/中断所有内容,它只会返回到调用我的控件构造函数的行。

This may be a long shot but I'm out of ideas.

I've got a VS C# solution with three projects in it. There's a class library project and then two application projects that depend on that class library. The class library in turn depends on a few other DLLs including the avalonedit dll from the sharpdevelop project.

One of the applications is building and running fine, including a use of my own control that wraps the avalonedit control. The other application is failing to run and it seems to be failing at the point when the avalonedit control is initialised via the XAML in my wrapping control.

The problem is that I don't see any errors in the debug output at all, all I see is the dll loaded message and then nothing. If I step into the constructor of my control the step never completes. The debugger says the app is running, but it is apparently spinning somewhere in the avalonedit dll when the underlying edit control is constructed by the XAML side.

I have to assume that there's some issue with difference in environment between the two projects but I'm kind of stumped as to how to proceed in tracking the problem down. Am I going to have to somehow get arrange matters so that I can put a break in the avalonedit source?

Edit: If I pause/break all it just drops back to the line calling my control constructor.

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

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

发布评论

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

评论(1

爱的那么颓废 2024-10-23 06:38:47

听起来像是陷入了僵局。仔细查看所有线程、它们的堆栈跟踪和同步原语(锁、信号量等)。请记住:争用的资源可能不是显式的(例如,当您在静态构造函数内等待尝试访问正在构造的类型的静态字段时,您会遇到死锁)。

有很多方法可以引入死锁,但没有简单的建议来处理它。您还可以在 Visual Studio 中启用所有异常的中断(调试 -> 异常...并勾选 CLR 异常)。

如果这没有帮助,您可以在此处提供堆栈跟踪,也许有人可以发现问题。

Sounds like a deadlock. Take a close look at all threads, their stack traces and synchronization primitives (locks, semaphores, etc.). Keep in mind: contended resources may not be explicit (for example, when you are inside static constructor waiting on something that tries to get access to a static field of the type being constructed you get a deadlock).

There are many ways to introduce a deadlock but no simple advice to handle it. You could also enable break on all exceptions in Visual Studio (Debug -> Exceptions... and tick CLR Exceptions).

If this does not help you could provide stack traces here and maybe somebody could spot the problem.

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