Share via


BizTalk Troubleshooting: Debug C# assembly invoked from orchestration

Introduction

At times we need to debug the C# class library that is being called from inside a BizTalk orchestration.  One way would be to have some logging within the class. But during any detail level investigation of an issue, it becomes necessary to step into the code during run time.

In order to achieve this, the PDB file is required which contains the necessary debug symbols for the debugger to step into the break points. To make PDB file available to be read, we need to copy this to GAC (global assembly cache) along with the DLL of the class library.

The below steps illustrates how can we use enable debugging the C# method that is called from an orchestration.

Steps

Copy PDB file to GAC

Copy the PDB file of the class library into GAC. The PDB file can be found in the bin\debug folder of the class library project. Note that the file needs to be copied to exact location within GAC as mentioned below.

C:\Windows\Assembly\GAC_MSIL\<DLL Folder>

Where <DLL Folder> is the name of actual Class library. An important point to note is that if you are using .Net Framework 3.5 or below the location will be different as shown below.

C:\Windows\Assembly\

Choose Appropriate BizTalk host instance

The next step will be to find the BizTalk host instance under which concerned orchestration is running. If there is only host instance, then that is by default hosting all the orchestrations. However, if there are multiple instances, we need to find exact host instance’s process id to correctly attach it to visual studio.

Open a command prompt and run below command which will list all the BizTalk running processes. (Make sure that all the BizTalk host instances are running on your machine).

tasklist /svc /fi "imagename eq btsnt*"

The above command will give a list of process ids for all the BizTalk host instances running on the machine. Note the process id for host instance which is configured in your orchestration which we are trying to debug (you can find this in BizTalk admin console under orchestration handler configuration).

Debugging

Once we know the processID , debugging is not normal as we do normally in Visual Studio.

  • Open class library project and add breakpoints wherever required.
  • Then go to Tool —>Attach process.
  • Select the option of showing the process from all the users and select the processid which was found as above.
  • Once we do that, the application will go into debug mode.
  • Post that run your BizTalk test which can instantiate the orchestration which is consuming the class library.
  • Once orchestration hits the relevant method of the class, the debugger will hit the break point in your class library code. You can do further analysis thereafter

See Also

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.