使用 c++ 的 C# 应用程序中的堆栈溢出动态链接库
我有一个 c# 程序,它使用 c++/cli 管理的 dll。该dll包含大量遗留代码,由相当多的win32窗口组成。
问题是,dll 中的窗口需要比平均水平多一点的堆栈空间咳。由于这些不是后台进程,而是 win32 api,我需要扩大 GUI 线程的堆栈大小(至少我认为 dll 中的 win32 api 将使用主 gui 进程)。
所以我需要一种方法来扩大ac#进程中GUI线程的大小。
由于我发现没有设置可以实现此目的,因此我尝试从命令行编辑 bin /STACK,这有效。问题是,它只能在命令行中工作,如果我出于某种原因尝试将其作为构建后步骤输入,则二进制文件的堆栈大小不会改变,即使构建后步骤已正确执行并且不会引发错误:(
editbin.exe /STACK:2097152 $(TargetPath)
(Editbin.exe 在路径中,并且输出窗口中没有错误)
那么如何为我的 c++ dll 获取更多堆栈大小?
[更新]
我注意到使用 editbin.exe 时出现问题
,这不起作用 。在命令行中或作为构建后步骤:
editbin.exe /STACK:2097152 c:\some\path\bin\release\app.exe
这在命令行中有效,但不能作为构建步骤:
editbin.exe /STACK:2097152 app.exe
但我需要它作为构建后步骤工作,我尝试将其放入批处理文件中,进行回显以确保调用。和工作目录都可以,但仍然不起作用。
I've got a c# program which is using a c++/cli managed dll. The dll contains a lot of legacy code, consisting of quite a few win32 windows.
Problem is, the windows in the dll need a bit more stackspace than average cough. Since these are not background processes but win32 api I need to enlarge the stack size of the GUI thread (at least I think the win32 api in the dll will use the main gui process).
So I need a way to enlarge the size of the GUI thread in a c# process.
Since I found no settings to achieve this I tried editbin /STACK from the command line, which works. Problem is, it only works in the command line, if I try to enter it as post-build-step for some reason the stack size of the binary does not change, even though the postbuild step is properly executed and throws no error :(
editbin.exe /STACK:2097152 $(TargetPath)
(Editbin.exe is in the path, and there is no error in the output window)
So how do I get more stack size for my c++ dll?
[Update]
I noticed a problem using editbin.exe.
This does not work, neither in command line nor as post build step:
editbin.exe /STACK:2097152 c:\some\path\bin\release\app.exe
This does work in command line, but not as build step:
editbin.exe /STACK:2097152 app.exe
But I need it to work as post build step. I tried to put it into a batch file, echo'd to make sure call and working dir are ok, but still it does not work. Strange.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不应该起作用,奇怪的是你没有收到构建错误。路径设置不正确,无法在 C# 构建中使用该工具。它确实可以从命令行运行,Visual Studio 命令提示符使用 C/C++ 项目的配置。这个构建后命令在 VS2008 中可以正常工作:
还要注意目标路径宏周围的双引号来处理空格。
This shouldn't work, odd that you don't get a build error. The path isn't set correctly to be able to use the tool in a C# build. It does work from the command line, the Visual Studio Command Prompt uses the config for a C/C++ project. This post-build command worked properly in VS2008:
Also note the double-quotes around the target path macro to deal with spaces.
这有帮助吗? /F(设置堆栈大小)
这是基本上提供 /F 开关以及要为堆栈保留的字节数。
Does this help? /F (Set Stack Size)
This is basically providing the /F switch along with the number of bytes you want to reserve for stack.