Windows could not start the Microsoft Dynamics CRM Asynchronous Processing Service service on… failed while monitoring asynchronous operations queue. System.NullReferenceException.

Hi,

I have successfully installed Dynamics CRM “R8” beta (Update Rollup 9) but then realized that the Dynamics CRM Asynchronous Processing Service was down. So, I tried to start it up and suddenly, came up with this error:

Windows could not start the Microsoft Dynamics CRM Asynchronous Processing Service on … . Error 1067: The process terminated unexpectedly.

image

As the error message was not so meaningful, I decided to take a look at the EventLog to see further details, finding out the following error:

image

Host URUIT-DYNCRM-R8: failed while monitoring asynchronous operations queue. Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Crm.Asynchronous.ServerConfiguration.CreateOrganizationConfiguration(PropertyBag organization, ServerRoles roles, Dictionary`2 newOrganizations, Dictionary`2 inactiveOrganizations)
   at Microsoft.Crm.Asynchronous.ServerConfiguration.<>c__DisplayClass5.<InitializeOrganizationList>b__0(IServiceOperation serviceOperation)
   at Microsoft.Crm.Asynchronous.Operations.OrganizationOperation.<get_EventAction>b__0(IServiceOperation operation)
   at Microsoft.Crm.Behaviors.FaultToleranceBehavior.Execute(ServiceOperationAction operation, IServiceOperation operationParameter)
   at Microsoft.Crm.Operations.MonitoredOperation.Execute()
   at Microsoft.Crm.Asynchronous.SequentialExecutionEngine.ExecuteSteps(IEnumerable`1 steps)
   at Microsoft.Crm.Asynchronous.SequentialExecutionEngine.ExecuteOperations(IEnumerable`1 operations)
   at Microsoft.Crm.Asynchronous.ServerConfiguration.InitializeOrganizationList()
   at Microsoft.Crm.Asynchronous.ServerConfiguration..ctor(ILocatorService locatorService, IServiceOperationsFactory operationsFactory)
   at Microsoft.Crm.Asynchronous.AsyncService.StartServiceComponents(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

 

Cause

It seemed to be a bug and actually it was, due to some columns missing in the DB, as stated in this MS Connect thread, which some colleagues have pointed me to.

Unfortunately it is not easy at all to find it for everybody and that’s why I decided to share here the solution.

 

Solution

In order to workaround this problem, it’s necessary to apply the following script to the MSCRM_CONFIG Database:

SET QUOTED_IDENTIFIER ON
GO
 
SET ANSI_NULLS ON
GO
 
DECLARE @XmlDoc xml
DECLARE @buildVersion nvarchar(max)
DECLARE @settingExists bit
DECLARE @changed bit
 
select @changed = 0
 
Select top 1 @buildVersion = BuildVersion from ConfigurationMetadata Order By InstalledOn desc
Select @XmlDoc = ConfigurationMetadataXml from ConfigurationMetadata where BuildVersion = @buildVersion
 
-- Add IsDisabledForAsyncProcessing to Organization table
Select @settingExists = @XmlDoc.exist('/metadata/tables/Table[@Name="Organization"]/Columns/Column[@Name="IsDisabledForAsyncProcessing"]')
if (@settingExists = 0)
begin
                    Set @XmlDoc.modify('insert     <Column Name="IsDisabledForAsyncProcessing">
                                                                                <Description>Specifies if async processing should be disabled for this organization</Description>
                                                                                                    <Type>bit</Type>
                                                                                                    <SchemaType>Settings</SchemaType>
                                                                                                    <Locator>1</Locator>
                                                                                                    <Cached>1</Cached>
                                                                                                    <IsWritable>1</IsWritable>
                                                                                                    <Default>0</Default>
                                                                                </Column>
                    after (/metadata/tables/Table[@Name="Organization"]/Columns/Column[@Name="MobileOrgName"])[1]')
 
                    select @changed = 1
end
 
-- Add RunAsyncServiceInSafeMode to DeploymentProperties
Select @settingExists = @XmlDoc.exist('/metadata/tables/Table[@Name="Deployment"]/Columns/Column[@Name="RunAsyncServiceInSafeMode"]')
if (@settingExists = 0)
begin
                    Set @XmlDoc.modify('insert <Column Name="RunAsyncServiceInSafeMode">
                                                            <Description>Specifies if async processing should be carried out in safe mode</Description>
                                                            <Type>bit</Type>
                                                            <SchemaType>Settings</SchemaType>
                                                            <Locator>1</Locator>
                                                            <Cached>1</Cached>
                                                            <IsWritable>1</IsWritable>
                                                            <Default>0</Default>
    </Column>
                    after (/metadata/tables/Table[@Name="Deployment"]/Columns/Column[@Name="AsyncSelectMaxItems"])[1]')
 
                    select @changed = 1
end
 
-- update ConfigurationMetadataXml
if (@changed = 1)
begin         
                    UPDATE ConfigurationMetadata Set ConfigurationMetadataXml = CAST(@XmlDoc AS nvarchar(max))
                    Where BuildVersion = @buildVersion
                   
                    UPDATE ConfigurationMetadata set ConfigurationMetadataXml = replace(CAST(ConfigurationMetadataXml AS nvarchar(max)), '&gt;', '>')
                    Where BuildVersion = @buildVersion
end
 
INSERT INTO  DeploymentProperties(Id, ColumnName, BitColumn)
                    SELECT Id, 'RunAsyncServiceInSafeMode', 0
                    FROM Deployment
                    WHERE Id NOT IN
                                        (SELECT dep.Id
                                        FROM Deployment dep
                                        JOIN DeploymentProperties depProp ON (dep.Id = depProp.Id)
                                        WHERE depProp.ColumnName = 'RunAsyncServiceInSafeMode')
 

After doing so, when trying again to start Dynamics CRM Asynchronous Processing Service, it worked like a charm for me :)

 

Hope it helps to save somebody else’s time and enjoy trying R8 beta, which is great! ;-)

 

PP [twitter: @pabloperalta]

UruIT Dynamix | Excellence in Dynamics CRM Nearshoring Services.

uruit_dynamix_016[2]

No Comments