I'm working with the same thing myself right now so I can only point you in the right direction.
"Application Name" is not a promoted property but other are promoted in your application.
You'll need the:
- connection string to your BizTalk Management Db, for example:
conn = "Data Source=localhost;Initial Catalog=BiztalkMgmtDb;Integrated Security=SSPI"
- Get a promoted property in your application:
if (inmsg.Context.Read("PortName", BTS_MSG_TRACKING_NAMESPACE) != null)
portName = inmsg.Context.Read("PortName", BTS_MSG_TRACKING_NAMESPACE) as string;
- Usage of BtsCatalogExplorer located in Microsoft.BizTalk.ExplorerOM:
BtsCatalogExplorer bc = new BtsCatalogExplorer(); bc.ConnectionString = conn; foreach (ReceivePort receivePort in bc.ReceivePorts) { if (portName == receivePort.Name) { applicationName = receivePort.Application.Name; } }
Note: If your code will run on multiple machines, you'll need to find the db server and instance name for each machine. Use the RegistryKey class in Microsoft.Win32 to extract your connection string data from
HKEY_CURRENT_USER\SOFTWARE\Microsoft\BizTalk Server\3.0\Tracking
MgmtDBServer
Edit:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration\MgmtDBServer
might be a better path.