It’s very common to use .NET code for orchestration support. In one of these scenarios, I decided to use a class to, in a certain way, validate the request and add more information, and to my surprise, I was blessed by this error:
An unhandled exception (‘<System.StackOverflowException>’) occurred in BTSNTSvc.exe [2756]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on.
Check the documentation index for ‘Just-in-time debugging, errors’ for more information.
📝 One-Minute Brief
This blog post identifies the cause and solution for a System.StackOverflowException occurring in BTSNTSvc.exe during BizTalk orchestration execution, specifically tracing it to an infinite loop in a custom .NET property definition.
And to further aggravate the situation, my Host Instance associated with the process stopped. The first action was reactivating the host instance! But to my surprise again! Automatically, the host instance stopped again!
First, let’s put some integration context…
Scenario
My team requested me, ASAP (this would be one of the problems ), to develop a method to change User Contact Information across different platforms. Basically, I get a request with different attributes, each of which is optiona,l and so I need:
- First, to read the user contact information from my Cache DB.
- See the fields that aren’t filled, and fill them with the cache information.
- Update the user information across different platforms.
- Update my database user information.
- …
So to accomplish that goal, I decided to create a Serializable public class UserProfile, and use this class as a variable inside the orchestration
How to begin “Debugging” the problem
First clue
- A StackOverflowException exception is thrown when the execution stack overflows by having too many nested method calls.
- Tips: Make sure you do not have an infinite loop or infinite recursion.
Second clue
- Because I was running different processes in that host instance, I had to validate which process was causing the error
- When I found the process, I found that no orchestration artifact is loaded, so the problem was in the Initialization of the artifact, but I cannot find an easy way to debug from Visual Studio.
Cause
It happens to everyone… I usually say that these kinds of problems are between the chair and the keyboard.
The cause of the problem was the definition of a variable of class UserProfile. I put in the return the name of the prop snippet instead of the variable, and this causes an infinite loop.
private string userFirstName = string.Empty;
///
/// User First and Last Name ///
public string UserFirstName
{
get
{
return UserFirstName;
}
set
{
userFirstName = value;
}
}
Solution
Easy, rectify the code.
The major difficulty in this scenario was how to find the error. I was able to debug the .NET stack using the Microsoft Symbol Server to obtain debug symbol files (https://docs.microsoft.com/en-us/windows/win32/dxtecharts/debugging-with-symbols) that I will explain a little more in one of my next posts.
Notes
- ASAP never works well
- Be aware of the copy –> paste
Last but not least, I want to thank Jorge Lourenço for help, who is one of the best technicians that I know with regard to detecting and solving problems
Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son.




1 thought on “BizTalk Error Message – An unhandled exception (‘System.StackOverflowException’) occurred in BTSNTSvc.exe”