locked
CRM 2011 RTM - Error in Import Solution through Plugin RRS feed

  • Question

  • Hi Community,

    In CRM 2011 RTM, I get error when importing Solution through plugin. Please provide your suggestions/help. Thanks in advance.

    Here is the code snippet that I try from Async plugin. It works fine when run from a Console Application though. Error occurs when it’s run from the Async plugin. Service account running CRM Async Service has full control on the Solution file and it can read all the bytes.

    Guid jobid = Guid.NewGuid();

    ImportSolutionRequest import = new ImportSolutionRequest();

    import.CustomizationFile = File.ReadAllBytes(@“C:\Test\TestSolution_1_0.zip”);

    import.ImportJobId = jobid;

    import.PublishWorkflows = publishWorkflows;

    import.OverwriteUnmanagedCustomizations = overwriteUnmanaged;

     

    ImportSolutionResponse importResp = (ImportSolutionResponse)service.Execute(import);

     

     

    Here is the Trace Log detail for the Error.

    [2011-04-18 22:22:22.588] Process:CrmAsyncService |Organization:2fa2d088-df55-e011-8b56-00155d5f7752 |Thread:    4 |Category: Exception |User: 7ca0007b-9bc8-4726-960e-2ca410bcd995 |Level: Error | CrmException..ctor

                    at CrmException..ctor(String message, Exception innerException, Int32 errorCode, Boolean isFlowControlException)

                    at CrmException..ctor(Exception innerException, Int32 errorCode, Object[] arguments)

                    at VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)

                    at Pipeline.Execute(PipelineExecutionContext context)

                    at MessageProcessor.Execute(PipelineExecutionContext context)

                    at InternalMessageDispatcher.Execute(PipelineExecutionContext context)

                    at ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, String messageName, String requestName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, ParameterCollection fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId, Guid transactionContextId, Int32 invocationSource, Nullable`1 requestId, Version endpointVersion)

                    at OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)

                    at OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)

                    at InprocessServiceProxy.ExecuteCore(OrganizationRequest request)

                    at SolutionManager.ImportSolution(IOrganizationService service, String fromFile, Boolean publishWorkflows, Boolean overwriteUnmanaged)

                    at ConfigureTaskableEntityPostCreate.ExecuteMessage(PhoenixPluginExecutionContext phoenixExecutionContext)

                    at MessageBasePlugin.ExecutePlugin(PhoenixPluginExecutionContext phoenixPluginExecutionContext)

                    at BasePlugin.Execute(IServiceProvider serviceProvider)

                    at V5ProxyPlugin.Execute(IServiceProvider serviceProvider)

                    at EventOperation.InvokePlugin(AsyncExecutionContext context, IPlugin pluginInstance)

                    at EventOperation.InternalExecute(AsyncEvent asyncEvent)

                    at AsyncOperationCommand.Execute(AsyncEvent asyncEvent)

                    at PoolHandler.ProcessAsyncEvent(AsyncEvent asyncEvent)

                    at PoolHandler.InvokeHandlerInPool(Object state)

                    at ExecutionContext.runTryCode(Object userData)

                    at RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)

                    at ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)

                    at QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()

                    at ThreadPoolWorkQueue.Dispatch()

                    at _ThreadPoolWaitCallback.PerformWaitCallback()

    >Crm Exception: Message: An unexpected error occurred., ErrorCode: -2147220970, InnerException: System.ArgumentNullException: Value cannot be null.

    Parameter name: str

       at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)

       at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)

       at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)

       at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)

       at System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping)

       at System.Web.HttpServerUtility.MapPath(String path)

       at Microsoft.Crm.Tools.ImportExportPublish.RootImportHandler.LoadAndValidateImportDocument(Boolean validate, Boolean hasSolutionManifest)

       at Microsoft.Crm.Tools.ImportExportPublish.ImportXml.RunImport()

       at Microsoft.Crm.Tools.ImportExportPublish.ImportXml.RunImport(Boolean withSolutionManifest)

       at Microsoft.Crm.WebServices.ImportXmlService.ImportSolution(Boolean overwriteUnmanagedCustomizations, Boolean publishWorkflows, Byte[] customizationFile, Guid importJobId, Boolean convertToManaged, ExecutionContext context)

    [2011-04-18 22:22:22.624] Process:CrmAsyncService |Organization:2fa2d088-df55-e011-8b56-00155d5f7752 |Thread:    4 |Category: Platform |User: 7ca0007b-9bc8-4726-960e-2ca410bcd995 |Level: Error | MessageProcessor.Execute

    >MessageProcessor fail to process message 'ImportSolution' for 'none'.

     

    As a side note, I had to GAC the DLLs (Microsoft.Deployment.Compression.Cab and Microsoft.Deployment.Compression – taken from C:\Program Files\Microsoft Dynamics CRM\CRMWeb\bin). Otherwise it gave me a File Not Found exception.

    >System.IO.FileNotFoundException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #EC1564CB: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Deployment.Compression.Cab, Version=3.0.0.0, Culture=neutral, PublicKeyToken=9f4be179981a58d1' or one of its dependencies. The system cannot find the file specified.

    >File name: 'Microsoft.Deployment.Compression.Cab, Version=3.0.0.0, Culture=neutral, PublicKeyToken=9f4be179981a58d1'

    >   at Microsoft.Crm.Tools.ImportExportPublish.RootImportHandler.TryParseCustomizationFileAsCab(CrmTemporaryFile customizationFile, CrmUnzip& customizationZip)

    >   at Microsoft.Crm.Tools.ImportExportPublish.RootImportHandler.ExtractZipDataFromCustomizationFile(CrmTemporaryFile customizationFile)

     

    Thanks,

    Chirag

    Tuesday, April 19, 2011 10:19 AM

Answers

  • I have done a little bit more investigation on this and importing a solution in a plugin is not really supported.  The metadata creation process gets tricky due to transaction support in plugins. 

    It MIGHT work sometimes, and it would probably depend on the components in the solution.  You could have your plugin call an external web site that could trigger the solution import.  This way you could break out of the transaction that the plugins are executing in.

    Thanks for the scenario though.  I will follow up with feature teams to see how we could enhance this in the future.

    Thanks,

    -Brandon

    • Proposed as answer by BSimons Wednesday, June 1, 2011 11:04 PM
    • Marked as answer by Jim Glass Jr Tuesday, June 7, 2011 8:36 PM
    Monday, May 23, 2011 5:18 AM

All replies

  • import.CustomizationFile = File.ReadAllBytes(@“C:\Test\TestSolution_1_0.zip”); <- Does your CRM IIS Application Pool have read access to this directory, and does it exist?
    • Proposed as answer by Travis_Sharp Tuesday, April 19, 2011 11:23 PM
    • Unproposed as answer by Chirag _CG Tuesday, April 19, 2011 11:49 PM
    Tuesday, April 19, 2011 11:15 PM
  • @Travis, the CRM IIS App Pool and CRM Async Service are running under Network Service. I have given Full Control access (for now) to the Network Service account on the "C:\Test" directory. Also, I can see that the Solution File is getting correctly Read as Bytes Array from the line "File.ReadAllBytes(@“C:\Test\TestSolution_1_0.zip”)". Just a FYI, I can as well write this Solution Bytes Array back to the existing/new file in "C:\Test" directory and then verify successfully that manually importing the solution works too.

    Please let me know if there's something else I should be taking care of.

    Thanks,

    Chirag

    Tuesday, April 19, 2011 11:54 PM
  • I am not sure what the overall design of your solution is, but I would suggest against using a plugin to import a solution.  The possibility of the import taking longer than 2 minutes to execute is pretty high.  Synchronous plugins can only execute for a maximum of 2 minutes.  Asynchronous plugins allow a single sdk call execute for 2 minutes. 

    For this error, you might be running into some sort of timeout issue. 

    -Brandon

    Thursday, April 21, 2011 11:05 PM
  • Hi,

    @Brandon, we need to have the CRM 2011 solution imported from plugin. Solution is a small one (approx. 100KB) and so the import would complete within 2 minutes. In the Trace Log, we do not see any timeout errors.

    Still waiting for help from Microsoft / Community on the error in this post and following:
    - Is it allowed to Import Solution from Plugin in CRM 2011?
    - How to Import Solution from Plugin in CRM 2011?

    Thanks
    Chirag

     




    Monday, April 25, 2011 6:48 AM
  • Hello -

    You can try setting the convert to managed flag on your request.  In a majority of cases, this should be false. 

    import.ConvertToManaged = convertToManaged;

    -Brandon

    Monday, April 25, 2011 6:31 PM
  • Hi Brandon,

    The convert to managed flag is a boolean  so already has the "false" value by default. Still, I set it to false and tried. But the same error.

    Awaiting community help.

    Thanks,

    Chirag

    Tuesday, May 3, 2011 6:29 AM
  • Hey,

      I get the import solution working from plugin registered on a prevalidation stage. Since Prevalidation is the only SYNCHRONOUS MODE PLUGIN, NOT WITH IN TRANSACTION.
      Import Solution service always seems to be failing at async mode with the mentioned error "ArgumentNullException: Value cannot be null".  Is that a known error  ? Any work around ?

    thanks

    Faiz


    Faizal Khan
    Wednesday, May 18, 2011 8:43 PM
  • I have done a little bit more investigation on this and importing a solution in a plugin is not really supported.  The metadata creation process gets tricky due to transaction support in plugins. 

    It MIGHT work sometimes, and it would probably depend on the components in the solution.  You could have your plugin call an external web site that could trigger the solution import.  This way you could break out of the transaction that the plugins are executing in.

    Thanks for the scenario though.  I will follow up with feature teams to see how we could enhance this in the future.

    Thanks,

    -Brandon

    • Proposed as answer by BSimons Wednesday, June 1, 2011 11:04 PM
    • Marked as answer by Jim Glass Jr Tuesday, June 7, 2011 8:36 PM
    Monday, May 23, 2011 5:18 AM