2

I am using Visual Studio 2013 Community version to write a C# project.

My program parses HTML using HtmlAgilityPack and raises a stack overflow exception. I've been trying to change the stack size but the solution property window I see only has the options as shown in the screenshot:

Visual Studio 2013 configuration properties missing

I've read some other articles which said that C# project's solution property panel's available options are different to that of C++. Where can I configure the stack size of my C# program?

Community
  • 1
  • 1
Daniel Kim
  • 79
  • 9
  • 2
    It is not exposed as an option in the C# compiler, you have to use a [postbuild event](http://stackoverflow.com/a/4089197/17034). The odds that this solves your problem are low, SOE is almost always caused by a bug in your program. – Hans Passant Nov 12 '15 at 11:40
  • Are you sure you don't have a endless loop in your program? (either a standard one from a while not ending or one where recursions don't stop. these are the default causes of stack overflows instead of anything else) – Thomas Nov 12 '15 at 12:04

1 Answers1

0

It seems that the reason behind this is the stack overflow. The issue can be resolved by increasing the stack size. In visual studio you can do this by using /STACK:reserve[,commit]. Read the MSDN article.

For more detailed explanation:

Under Windows platforms, the stack size information is contained in the executable files. It can be set during compilation in Visual studio C++. Alternatively, Microsoft provides a program editbin.exe which can change the executable files directly. Here are more details:

Windows (during compilation):

Select Project->Setting.
Select Link page.
Select Category" to "Output.
Type your preferred stack size in Reserve: field under Stack 
allocations. eg, 32768 in decimal or 0x20000 in hexadecimal.

Windows (to modify the executable file):

There are two programs included in Microsoft Visual Studio, dumpbin.exe and editbin.exe. Run dumpbin /headers executable_file, and you can see the size of stack reserve information in optional header values. Run editbin /STACK:size to change the default stack size.

Bilal Sohail
  • 129
  • 9