Often you must have noticed that importing solution often slows down CRM to the extent that it is almost unusable for the period during which the Import action is being processed.
To improve performance, a new request has been introduced in CRM 2013 which supports to importing solutions asynchronously. This is however available only to developers and the Import Solution action from the CRM Interface still locks CRM out for any practical use by CRM users.
For this we need to use ExecuteAsyncRequest which will be executed as an asynchronous process.
We need to submit this request using Organization Service and the message will submit an asynchronous job to process. You will receive an id of this async job which has been submitted. Through this id you can identify whether a solution has been imported successfully or the solution failed.
Below is the code snippet which can be used to Import the solution asynchronously.
ExecuteAsyncRequest request = new ExecuteAsyncRequest
Request = new ImportSolutionRequest
//set the compressed solutions file path to import
CustomizationFile = File.ReadAllBytes(solutionFilePath),
//set whether any processes (workflows) included in the solution should be activated after they are imported
PublishWorkflows = true,
//set whether any unmanaged customizations that have been applied over existing managed solution components should be overwritten
OverwriteUnmanagedCustomizations = true,
ExecuteAsyncResponse response = (ExecuteAsyncResponse)_service.Execute(request);
In the response of this request you will get a async job id as highlighted below:
You can simply navigate to the System Jobs area and you will find the job submitted in CRM and you can see the status of this job whether the import succeeded or failed.
The main advantage of an asynchronous solution import is, the users who are interacting with the system will not face SQL timeout issues when the solution is being imported asynchronously.