Debugging .NET assembly Template Building Blocks remotely
If the Visual Studio developer environment and the Content Manager Server are running on different machines, enable remote debugging in Visual Studio (consult your Visual Studio documentation to learn how), and attach your Visual Studio debugger to the Template Debug Host on the other machine running the Visual Studio Remote Debugging Monitor.
Procedure
- Access the machine on which the Content Manager server runs.
- Ensure that a new .NET assembly can be uploaded to the Content Manager as a Template Building Block. Refer to Creating a .NET assembly Template Building Block to learn how. Be sure to configure the upload tool to include .pdb files when uploading the assembly; these files are used for debugging.
- Start the Visual Studio Remote Debugging Monitor (as the user who is running Visual Studio on the client machine) using the executable called msvsmon.exe located in the folder:
<VisualStudioInstallationPath>\Microsoft Visual Studio\Common7\IDE\Remote Debugger\<arch>\
where
<arch>is the architecture of the CPU on your client machine (eitherx64,ia64, orx86).You can choose to share this folder so that the Content Manager server machine can access it.
Be sure to run this executable as the user who is running Visual Studio on the client machine. You can do this, for example, from the Windows command line prompt using the
runascommand. The user must be a local administrator on the Content Manager server machine. - On your client machine, start Visual Studio and open the .NET assembly project.
- Also, start Template Builder and open or create a Compound Template.
- Set a breakpoint somewhere in your code.
- From the main menu, select Debug > Attach to Process.
The Attach to Process dialog appears.
- In this dialog:
- For Qualifier, fill in the name of the Content Manager server machine, for example,
username@TCMSERVER, whereusernameis the name of the user who is running msvsmon.exe. Then click Refresh at the bottom of the dialog.The Available Processes table now displays processes running on the Content Manager server machine.
- In this table, locate the running process called TcmTemplateDebugHost. In that case, identify your specific instance of this process by checking the ID. You can find out the ID of your process by checking the Output view in Template Builder, which contains the following line:
Debugging was started in process 'TcmTemplateDebugHost' with ID 7728where
7728is the ID of the process.Note: You can also debug a .NET Template Building Block from the Content Manager Explorer interface while you preview or publish a Component or Page. To do so, you must attach to a different process:- To debug while previewing, attach to DLLHost.exe (if you see multiple entries for DLLHost.exe, attach to all of these processes)
- To debug while publishing, attach to TcmPublisher.exe and to DLLHost.exe (if you see multiple entries for DLLHost.exe, attach to all of these processes)
The debugger now attaches itself to the process.
Note the following:
- If, during debugging, you experience problems working with TcmTemplateDebugHost, try closing it down. It automatically restarts when needed.
- To be able to detach from a process when you finish debugging (you are otherwise forced to quit the process after debugging), in the Attach to Process dialog, go to the Attach to subdialog, select Debug these code types and select the Managed Code option.
- For Qualifier, fill in the name of the Content Manager server machine, for example,