调用非托管 DLL 时 vshost32.exe 崩溃

发布于 2024-07-17 06:42:12 字数 388 浏览 4 评论 0原文

我正在使用 VS 2005 应用程序与非托管 (Fortran) DLL 进行交互。 当我直接从命令行运行编译后的可执行文件时,一切都很好 - 可以访问 DLL,并且我可以使用 DLL 中的函数。

不幸的是,当我从 VS 2005 启动该应用程序时,我收到一个弹出窗口,指出“vshost32.exe 已停止工作”,并且没有有用的调试信息。

有没有人经历过这种行为,或者知道为什么会发生这种情况? 我不明白为什么它在独立启动时可以正常运行,但不能通过 vshost32 运行。

(最后一点:我正在使用 .local 文件强制从 cwd 使用注册的 dll,但是这个特定的 dll 没有注册。我只是在这里指出它,以防它有帮助。)


非常感谢,

Mike

I'm using a VS 2005 app to interface against an unmanaged (Fortran) DLL. When I run the compiled executable straight from the command line, everything is fine - the DLL can be accessed, and I can work with the functions in the DLL.

Unfortunately, when I launch the app from VS 2005, I get a popup stating "vshost32.exe has stopped working" and no useful debugging information.

Has anyone experienced this behavior, or know why this might be occuring? I can't figure out why it would run fine when launched stand-alone, but not via vshost32.

(One last note: I am using .local files to force registered dlls to be used from cwd, but this particular dll is not registered. I'm just noting it here in case it helps.)


Thanks very much,

Mike

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

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

发布评论

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

评论(5

埋情葬爱 2024-07-24 06:42:12

我遇到了 vshost32.exe 崩溃的问题,当我选中复选框时,问题就消失了:

Properties -> 调试-> 启用非托管代码调试

它适合您吗?

编辑:在更新的版本中,该选项被称为:启用本机代码调试(感谢 Qwerty01)

编辑:它似乎在 VS2008 中也有帮助( @Deacon Frost),VS2010(@Alxandr)。

I had problem with crashes of vshost32.exe the problem vanished when I checked the checkbox:

Properties -> Debug -> Enable unmanaged code debugging

Does it work for you?

EDIT: In more recent versions the option is called: Enable native code debugging (thanks Qwerty01)

EDIT: It also seems to help in VS2008 (@Deacon Frost), VS2010 (@Alxandr).

白色秋天 2024-07-24 06:42:12

不确定,但您可以从属性 -> 禁用 Visual Studio 托管进程的使用 调试

Not sure but you can disable use of the visual studio hosting process from Properties -> Debug

谁对谁错谁最难过 2024-07-24 06:42:12

可能存在未处理的异常。 您可以尝试添加以下代码来处理所有未捕获的异常:

static void Main()
{
  // Add a handler for the UnhandledExceptionEvent
  AppDomain.CurrentDomain.UnhandledException +=
    new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

  Application.EnableVisualStyles();
  Application.SetCompatibleTextRenderingDefault(false);
  Application.Run(new Form1());
}

static void CurrentDomain_UnhandledException
     (object sender, UnhandledExceptionEventArgs e)
{
    try
    {
        Exception ex = (Exception)e.ExceptionObject;

        MessageBox.Show(ex.ToString(), "Error", 
              MessageBoxButtons.OK, MessageBoxIcon.Stop);
    }
    finally
    {
        Application.Exit();  
    }
}

根本问题的原因是您在调试时可能有不同的工作文件夹,从而找不到您的本机库。

Might be that there is an unhandled exception. You could try to add the following code to handle all uncatched exceptions:

static void Main()
{
  // Add a handler for the UnhandledExceptionEvent
  AppDomain.CurrentDomain.UnhandledException +=
    new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

  Application.EnableVisualStyles();
  Application.SetCompatibleTextRenderingDefault(false);
  Application.Run(new Form1());
}

static void CurrentDomain_UnhandledException
     (object sender, UnhandledExceptionEventArgs e)
{
    try
    {
        Exception ex = (Exception)e.ExceptionObject;

        MessageBox.Show(ex.ToString(), "Error", 
              MessageBoxButtons.OK, MessageBoxIcon.Stop);
    }
    finally
    {
        Application.Exit();  
    }
}

The reason for the underlying problem is that you might have a different working folder when debugging so that your native library is not found.

梦里泪两行 2024-07-24 06:42:12

我正在使用 Visual C# 2010 Express。 我能够通过导航到 Project -> 来阻止 vshost32 崩溃。 特性。 我单击“调试”选项卡并取消选中“启用 Visual Studio 托管进程”复选框。

I am using Visual C# 2010 Express. I was able to stop the vshost32 crashes by navigating to Project -> Properties. I clicked on the Debug tab and unchecked the "Enable the Visual Studio hosting process" checkbox.

稀香 2024-07-24 06:42:12

下载依赖步行器
http://www.dependencywalker.com/
用它打开你的 dll,看看它是否依赖于该文件夹中不存在的其他 dll。

download dependency walker
http://www.dependencywalker.com/
use it to open up your dll, and see if it relies on other dlls that are not present in that folder.

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