StackoverflowException in IIS7 but not in Cassini

2019-07-24 22:23发布

问题:

I have some C# code that is giving a StackOverflowException when running under IIS7 but when it is run under Cassini in VS2008 then the code runs fine.

Is this a known issue whereby Cassini handles these kinds of exceptions differently?

回答1:

The IIS runtime uses a different stack size for threads. IIRC it is 256 KB as opposed to the standard 1 MB you get when running on the standard .NET runtime, which is the one VS uses. In other words, you may have code that runs fine under the regular .NET runtime, but which exhausts the stack under IIS.

From looking at Cassini it sounds like it uses the regular .NET runtime, so I would expect it to use a stack size of 1 MB per thread as well.



回答2:

you can change the stack size using the EDITBIN command. or change it by creating yourown thread with required stack size