Microsoft.biztalk.explorerom.btsca talogexplorer.savechanges() Exception:Could not enlist orchestration

Hi All,

We have BizTalk2010(with SQL remote). When I am trying to Start BizTalk Application using below PowerShell I am getting below error.

Exception calling "SaveChanges" with "0" argument(s): "Could not enlist orchestration"

Exception has been thrown by the target of an invocation.Client requested abort.Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

PowerShell Script:

function StartBTSApplication
{
 param([string]$applicationName)
 trap { Write-Output "Error" }
 $exp = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
    
 $exp.ConnectionString = "server=NTFWSQLD2\DEV1;database=BizTalkMgmtDb;Integrated Security=SSPI"
    $exp.ConnectionString = $btsConnectionString
 $app = $exp.Applications[$applicationName]
 if($app -eq $null)
 {
  Write-Output "Application $applicationName not found"
 }
 else
 {
  if($app.Status -ne 1)
  {  
   #full start of application
   $null = $app.Start(63)
   $null = $exp.SaveChanges() # SaveChanges method not able to commit the changes on BT databases
   Write-Output "Started application: $applicationName"
  }

Few Observations:

1). Getting this error only for newly insatlled application, If any application was at least one time started mannually on BT console, I am able to start it again using the same script (Using PowerShell console 32 bit and PowerShell ISE).

2). Able to start newly installed application as well, if I run this script with PowerGUI script editor tool.

3). I have refered the below link and added the Powershell.exe.config file but still no luck.

http://psbiztalk.codeplex.com/discussions/252593

Please let me know if i am doing any thing wrong.

Regards,
Satendra Bhadouria



October 24th, 2012 3:04am

It looked like you were not using the Start-Application cmdlet. Did you try using this syntax:

Start-Application -Path MyApp -StartOption StartAll

This cmdlet is in the psbiztalk snap-in.

Thanks,

Free Windows Admin Tool Kit Click here and download it now
October 24th, 2012 9:11pm

Maybe it makes sense to add host restart to this script? (I don't know how to do this.)
October 24th, 2012 9:59pm

Make sure you start all the application dependencies.  In C# it's something like the following. Note the recursive call.

                #region Start Application
                Application application = GetBtsCatalogExplorer().Applications[applicationName];

                if (application != null)
                {
                    foreach (Application app in application.References)
                    {
                        if ((app.Status != Status.Started) && (app.Status != Status.NotApplicable))
                        {
                            ControlApplication(app.Name); // Recursive call to start application
                        }
                    }

                    using (BtsCatalogExplorer catalog = GetBtsCatalogExplorer())
                    {
                        if (catalog.Applications[applicationName].Status != Status.Started)
                        {
                                if (displayed[applicationName] == null)
                                {
                                    Console.WriteLine("Starting application: {0}", applicationName);
                                    displayed.Add(applicationName, applicationName);
                                }

                                // Now start this application
                                catalog.Applications[applicationName].Start(ApplicationStartOption.StartAll);

                                // Commit the change
                                catalog.SaveChanges();
                        }
                    }
                }
                else
                {
                    throw new ApplicationException(string.Format("Invalid application specified.  Name: {0}", applicationName));
                }
                #endregion

NOTE:  Use the PS restart-service to restart host instances and IIS reset to stop out of proc host inst

Free Windows Admin Tool Kit Click here and download it now
October 25th, 2012 1:42am

Thanks Ben for suggestion. I have Installed the BizTalkFactory PowerShell Provider 1.2.0.4 for BizTalk Server 2010 from http://psbiztalk.codeplex.com/ and able to Start BizTalk Application using cmdlet: Start-Application -Path MyApp -StartOption StartAll

But still i am not able to resolve the issue i mentioned in my post with Microsoft.biztalk.explorerom.btscatalogexplorer.savechanges() Exception.

Please let me if you find any thing I am missing in deployment process.

Satendra Bhadouria

October 25th, 2012 6:36am

Leonid,

I have tried restarting the Host as well but still getting the same error.

Free Windows Admin Tool Kit Click here and download it now
October 25th, 2012 6:38am

Is the orchestration already bound to ports? I think this error can happen when the orchestration has not yet been bound to ports.

Thanks,

October 25th, 2012 3:00pm

If you are using .bat or .cmd file to call the  .ps1 script make sure you run the powershell script using C:\WINDOWS\System32\windowspowershell\v1.0\powershell.exe.
Free Windows Admin Tool Kit Click here and download it now
November 19th, 2013 5:49am

For all of those that ran into this issue and couldn't solve it. This is how I solved it. I was running ISE for 64 bit and decided to switch over the to the ISE (x86). I ran into another problem about not finding some different references which made no sense to me. After a bunch of research I added configuration files in the following places: 

C:\Windows\System32\WindowsPowerShell\v1.0

C:\Windows\SysWOW64\WindowsPowerShell\v1.0

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup>
      <supportedRuntime version=
"v4.0.30319" />
    </startup>
</configuration>


 I named them powershell_ise.exe.config. I wasn't using the tool provided by Ben Cline and company just a powershell script leveraging the Biztalk.ExplorerOM. 

What I have discovered is that the Powershell engine works just fine under .NET 4.0 but the ISE and the shell don't work with it out of the box as they target .NET 2.0. Once I added the configuration file the errors went away. 


July 2nd, 2015 7:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics