Archive

Starting with the .NET Framework version 2.0, a StackOverflowException object cannot be caught by a try-catch block and the corresponding process is terminated by default.

Really? Why have the exception then anyway? So you can throw it yourself? And to be catch by whom?
I think that there are more graceful ways to end your process than throw new StackOverflowException ();

Consequently, users are advised to write their code to detect and prevent a stack overflow. For example, if your application depends on recursion, use a counter or a state condition to terminate the recursive loop.

I totally agree that StackOverflowException is the result of a serious problem in your application. But what happens if you cannot avoid recursion? You cannot control the stack size and how would you find out the value of such a counter?

Should you not have a graceful way of treating this, rather than having your process shut down?

I’m not a .Net expert, but I think this breaks the entire meaning of a managed runtime environment.

“What? No XPath2 in .Net? Only v1?”
This is how it starts. At first you can call Microsoft however you want for not implementing XPath2, not even in .Net framework 4. But then you should come together and do it yourself. Actually doing a small workaround, that will enable you to use XPath2 functions in .Net.
First of all see the difference between the XPath functions implemented by Microsoft and the XPath2 standard functions.
Most likely for XSLT transformation in .Net you will use XslCompiledTransform. The workaround is based on adding an extension object.

For the sake of example and simplicity I included in here only two example functions, compare and replace. But you can implement here all the XPath2 functions that you need, as methods (not static ones) of the class XPath2.

as the first line. And then using any function will be simple and straightforward:

<xsl:value-of select="xpath2:compare('xpath1', 'xpath2')" />

Of course another way will be to simply use Saxon, an open source implementation for XSLT 2 for both Java and .Net. But if you just need an XPath2 function, it should be simpler what I described above.