Wednesday 24 July 2013

Conversion job settings cannot be changed after items have been added to the job in word automation services in Sharepoint 2013

Hi,

An issue was reported to me where an exception was coming while my admins were trying to use word automation services to convert some word documents in pdf format. They were constantly facing with this exception :

System.InvalidOperationException was unhandled
  HResult=-2146233079
  Message=Conversion job settings cannot be changed after items have been added to the job.
  Source=Microsoft.Office.Word.Server
  StackTrace:
       at Microsoft.Office.Word.Server.Conversions.ConversionJobSettings.set_OutputFormat(SaveFormat value)
       at WordAutomationService.Program.Main(String[] args) in
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

After reviewing the source code I found following:

                    cJob.AddLibrary(sourceList, destList);
                    ConversionJobSettings settings = rahulJOb.Settings;
                    settings.OutputFormat = SaveFormat.PDF;
                     cJob.Start();
In the highlighted lines it is evident that the job settings were tried to modified after adding source and destination document libraries. The code was modified and the highlighted lines were moved above the
cJob.AddLibrary(sourceList, destList) and the issue was confirmed to be resolved.

I hope this will help you out.

Thanks,
Rahul Rashu

No comments:

Post a Comment