Programmatically remove Biztalk Assembly resource from an Application

Programmatically remove Biztalk Assembly resource from an Application

Here is a short C# code snippet about how to remove a BizTalk assembly resource from a BizTalk application.

To use this code you have to add BizTalk.Application.Deployment.Engine.dll (located in the BizTalk installation folder) and Microsoft.BizTalk.Admin.dll (located in the GAC) as reference.

public static void RemoveAssemblyResource(
   string pAssemblyDisplayName,
   string pApplicationName,
   string pServerName,
   string pMgmtDatabase)
{
   Microsoft.BizTalk.ApplicationDeployment.Group lDepGroup =
      new Microsoft.BizTalk.ApplicationDeployment.Group();

   try
   {
      lDepGroup.DBName = pMgmtDatabase;
      lDepGroup.DBServer = pServerName;

      Microsoft.BizTalk.ApplicationDeployment.Application lApp =
         lDepGroup.Applications[pApplicationName];

      if (lApp.IsSystem)
         throw new Exception("System applications can not be changed!");

      lApp.ResourceCollection.Remove(string.Empty, pAssemblyDisplayName);
   }
   catch
   {
      lDepGroup.Abort();
      throw;
   }
   finally
   {
      lDepGroup.Dispose();
   }
}

One thought on “Programmatically remove Biztalk Assembly resource from an Application

  1. Pingback: Websites tagged "biztalk" on Postsaver

Leave a Reply

Your email address will not be published. Required fields are marked *