BizTalk Error Message – An unhandled exception (‘System.StackOverflowException’) occurred in BTSNTSvc.exe

It’s very common to use .NET code for orchestration support. In one of these scenarios, I decide to use a class for, 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.

Event Properties StackOverflowException

And to further aggravate the situation my Host Instance associated with the process stopped. The first action was reactivating the host instance! But for my surprise again! Automatically the host instance stopped again!

Event Viewer Overview StackOverflowException

First, let 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 them is optional and so I need:

  • First to read the user contact information from my “Cache” DB
  • See the fields that aren’t filled, and filled them with the cache information
  • Update the user information across different platforms
  • Update my database user information
User Contact Information SCENARIO

So to accomplish that goal, I decide to create a Serializable public class UserProfile and use this class as a variable inside the orchestration

UserProfile variable

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 load, 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 with copy –> paste

Last but not least, I want to thank Jorge Lourenço for help, which is one of the best technicians that I know with regard to detecting and solving problems

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

turbo360

Back to Top