Stack overflow in c# app using c++ dll

☆樱花仙子☆ 提交于 2019-12-21 16:57:08

问题


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.


回答1:


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:

set path=%path%;$(DevEnvDir);$(DevEnvDir)..\..\vc\bin
editbin.exe /STACK:2097152 "$(TargetPath)"

Also note the double-quotes around the target path macro to deal with spaces.




回答2:


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.



来源:https://stackoverflow.com/questions/5538477/stack-overflow-in-c-sharp-app-using-c-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!