Need to get the Current Biztalk Application Name

Rahul A 61 Reputation points
2021-02-11T20:10:41.547+00:00

HI,

I need to get the current Biztalk Application name under which my Custom Disassembler is running.
With the below code, I get all the applications list.

Is there any way for me to get only the application under which my code(Custom disassembler code) is running.

BtsCatalogExplorer catalog = new BtsCatalogExplorer();
catalog.ConnectionString = "SERVER=.;DATABASE=BizTalkMgmtDb;Integrated Security=SSPI";

        //string applicationName = args[1];  
        ApplicationCollection app = catalog.Applications;  

67104-b1.png

Microsoft BizTalk Server
Microsoft BizTalk Server
A family of Microsoft server products that support large-scale implementation management of enterprise application integration processes.
358 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jonas Grundén 76 Reputation points
    2021-03-02T13:54:13.023+00:00

    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:

    1. connection string to your BizTalk Management Db, for example:
            conn = "Data Source=localhost;Initial Catalog=BiztalkMgmtDb;Integrated Security=SSPI"
    
    1. 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;
      
    2. 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.


0 additional answers

Sort by: Most helpful