SharePoint 2013: Conversion Job Settings cannot be Changed after Items have been Added to the Job in Word Automation Services

SharePoint 2013: Conversion Job Settings cannot be Changed after Items have been Added to the Job in Word Automation Services

An issue was reported to me where an exception was generated 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 the following:
1.cJob.AddLibrary(sourceList, destList);
2.ConversionJobSettings settings = rahulJOb.Settings;
3.settings.OutputFormat = SaveFormat.PDF;
4.cJob.Start();

In the code above it is evident that the job settings were tried to be modified after adding source and destination document libraries. The code was modified and the lines 2 and 3 were moved above the
cJob.AddLibrary(sourceList, destList) and the issue was confirmed to be resolved.
Leave a Comment
  • Please add 3 and 1 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Naomi  N edited Original. Comment: Title case

Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Naomi  N edited Original. Comment: Title case

Page 1 of 1 (1 items)