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

Posted: May 11, 2011 in BizTalk
Tags: , ,

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 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 to the process stopped. First action was to reactive the host instance! But for my surprise again! Automatically the host instance stopped again! Sorriso

Event-Viewer-Overview-StackOverflowException

First, let put some integration context…

SCENARIO

My team requested me, ASAP (this would be one of the problems Sorriso), 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 Sorriso.

The cause of the problem was in 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 cause an infinite loop.

private string userFirstName = string.Empty;
/// <summary>
/// User First and Last Name
/// </summary>
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 (http://support.microsoft.com/kb/311503) that I will explain a little more in one of my next posts.

Notes:

  • ASAP never works well Sorriso
  • 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 in regard to detecting and solving problems

Tags: BizTalk | Orchestration | Errors and Warnings, Causes and Solutions

Comments
  1. […] BizTalk Error Message – An unhandled exception (‘System.StackOverflowException’) o… […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s