views:

36

answers:

1

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?

+2  A: 

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.

Brian Rasmussen
Excellent, this looks like it was the issue. Just need to see if I can fix it now.
nelsona
@nelsona: Glad I could help. If you launch the threads yourself, there's a constructor, that allows you to set the stack size. The default stack size can also be set by changing the PE header of the executable.
Brian Rasmussen
@Brian Rasmussen I am using the ideas in this post: http://blogs.msdn.com/b/tom/archive/2008/03/31/stack-sizes-in-iis-affects-asp-net.aspx to get the thing to work :-)
nelsona