This post disappeared from a previous blog of mine so I'm reposting it.
—
A couple of weeks ago I wrote a short article about an ‘easy’ method of determining the correct BTSNTSvc.exe process to attach to in VS.NET in order to debug orchestration utility components. Scott Colestock described a better way to determine this here.
I liked his method much better than mine but I didn’t want to have Perfmon open whenever I needed to find the correct process id. I took his suggestion one step further and created a simple console application that writes out the process ids of all started, in-process host instances. Here are the steps to create (using C#) and use this simple application:
- Create a new .NET console application.
- Add a reference to System.Management.dll
- In the class that contains your main() method add using statements for:
- System.Diagnostics
- System.Management
- Add the following code to the main() method:
//Enumerate all HostInstances of "InProcess" type
try
{
//Create EnumerationOptions
EnumerationOptions enumOptions = new EnumerationOptions();
enumOptions.ReturnImmediately = false;
//Search for all HostInstances of 'InProcess' type in the Biztalk namespace scope
ManagementObjectSearcher searchObject = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer","Select * from MSBTS_HostInstance where HostType=1 and ServiceState=4",enumOptions);