COM target does not implement IDispatch

I have this method to create reports:

/// <summary>
/// Retrieves the results of the analyze files tasks and generates a standard report.
/// </summary>
private void CreateReports(FileBasedProject project, string reportDir, List<string> trgLocales, List<Guid> reportIds, List<string> reportFileNames, bool spreadsheetReport) { string reportExtension = spreadsheetReport ? ".xls" : ".xml"; ReportFormat reportFormat = spreadsheetReport ? ReportFormat.Excel : ReportFormat.Xml; for (int i = 0; i < trgLocales.Count; i++) { Guid reportId = reportIds[i]; string report = reportDir + Path.DirectorySeparatorChar + reportFileNames[i] + '_' + GetSafeFileName(DateTime.Now.ToString(CultureInfo.CurrentCulture)) + reportExtension; project.SaveTaskReportAs(reportId, report, reportFormat); Utilities.FileOrDirExists(report); Log.Info("Report created for target locale " + trgLocales[i] + ": " + report); } }

However when I run this for a project with say 10 languages, 2000 files, and choose to export in Excel format, I get:

ERROR 30/Jul/2015 13:02:54 MyProgram.Program.Main(:0): System.Reflection.TargetInvocationException: COM target does not implement IDispatch.
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Sdl.ProjectApi.Reporting.XmlReporting.ExcelReportRenderer.GetExcelVersion(Object app)
   at Sdl.ProjectApi.Reporting.XmlReporting.ExcelReportRenderer.RenderReport(String xml, ReportDefinition reportDefinition, ReportFormat format)
   at Sdl.ProjectApi.Reporting.XmlReporting.XmlTaskReportRenderingEngine.RenderReport(ITaskReportInstance taskReportInstance, ReportFormat format)
   at Sdl.ProjectApi.Implementation.Report.SaveAs(String targetFilePath, ReportFormat format)
   at Sdl.ProjectAutomation.FileBased.FileBasedProject.SaveTaskReportAs(Guid reportId, String path, ReportFormat reportFormat)
   at MyProgram.ProjectCreator.CreateReports(FileBasedProject project, String reportDir, List`1 trgLocales, List`1 reportIds, List`1 reportFileNames, Boolean spreadsheetReport, String projectName)
   at MyProgram.ProjectCreator.Create(List`1 docFolders, List`1 tmFiles, List`1 bilingualPaths, String projectTemplate, List`1 settingsFiles, String reportDir, String assignmentAlias, Boolean recursion, Boolean reportCrossFileRepetitions, Boolean reportInternalFuzzyMatchLeverage, Boolean keepProjectFiles, Boolean preTranslateFiles, Boolean generateTargetTranslations, Boolean compareGeneratedFiles, Boolean spreadsheetReport)
   at MyProgram.Program.Main(String[] args)

Today I also got:

ERROR 31/Jul/2015 09:27:58 MyProgram.Program.Main(:0): System.Exception: No xml report renderer found for format 'Excel'.
   at Sdl.ProjectApi.Reporting.XmlReporting.XmlReportRendererConfiguration.GetXmlReportRenderer(String format)
   at Sdl.ProjectApi.Reporting.XmlReporting.XmlTaskReportRenderingEngine.RenderReport(ITaskReportInstance taskReportInstance, ReportFormat format)
   at Sdl.ProjectApi.Implementation.Report.SaveAs(String targetFilePath, ReportFormat format)
   at Sdl.ProjectAutomation.FileBased.FileBasedProject.SaveTaskReportAs(Guid reportId, String path, ReportFormat reportFormat)
   at MyProgram.ProjectCreator.CreateReports(FileBasedProject project, String reportDir, List`1 trgLocales, List`1 reportIds, List`1 reportFileNames, Boolean spreadsheetReport, String projectName)
   at MyProgram.ProjectCreator.Create(List`1 docFolders, List`1 tmFiles, List`1 bilingualPaths, String projectTemplate, List`1 settingsFiles, String reportDir, String assignmentAlias, Boolean recursion, Boolean reportCrossFileRepetitions, Boolean reportInternalFuzzyMatchLeverage, Boolean keepProjectFiles, Boolean preTranslateFiles, Boolean generateTargetTranslations, Boolean compareGeneratedFiles, Boolean spreadsheetReport)
   at MyProgram.Program.Main(String[] args)

Parents
  • Can you please try .xlsx as report format instead of .xls?

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • I still get this error message:
    ERROR 31/Jul/2015 11:19:24 MyProgram.Program.Main(:0): System.Reflection.TargetInvocationException: COM target does not implement IDispatch.
    at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
    at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
    at Sdl.ProjectApi.Reporting.XmlReporting.ExcelReportRenderer.GetExcelVersion(Object app)
    at Sdl.ProjectApi.Reporting.XmlReporting.ExcelReportRenderer.RenderReport(String xml, ReportDefinition reportDefinition, ReportFormat format)
    at Sdl.ProjectApi.Reporting.XmlReporting.XmlTaskReportRenderingEngine.RenderReport(ITaskReportInstance taskReportInstance, ReportFormat format)
    at Sdl.ProjectApi.Implementation.Report.SaveAs(String targetFilePath, ReportFormat format)
    at Sdl.ProjectAutomation.FileBased.FileBasedProject.SaveTaskReportAs(Guid reportId, String path, ReportFormat reportFormat)
    at MyProgram.ProjectCreator.CreateReports(FileBasedProject project, String reportDir, List`1 trgLocales, List`1 reportIds, List`1 reportFileNames, Boolean spreadsheetReport, String projectName)
    at MyProgram.ProjectCreator.Create(List`1 docFolders, List`1 tmFiles, List`1 bilingualPaths, String projectTemplate, List`1 settingsFiles, String reportDir, String assignmentAlias, Boolean recursion, Boolean reportCrossFileRepetitions, Boolean reportInternalFuzzyMatchLeverage, Boolean keepProjectFiles, Boolean preTranslateFiles, Boolean generateTargetTranslations, Boolean compareGeneratedFiles, Boolean spreadsheetReport)
    at MyProgram.Program.Main(String[] args)
Reply
  • I still get this error message:
    ERROR 31/Jul/2015 11:19:24 MyProgram.Program.Main(:0): System.Reflection.TargetInvocationException: COM target does not implement IDispatch.
    at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
    at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
    at Sdl.ProjectApi.Reporting.XmlReporting.ExcelReportRenderer.GetExcelVersion(Object app)
    at Sdl.ProjectApi.Reporting.XmlReporting.ExcelReportRenderer.RenderReport(String xml, ReportDefinition reportDefinition, ReportFormat format)
    at Sdl.ProjectApi.Reporting.XmlReporting.XmlTaskReportRenderingEngine.RenderReport(ITaskReportInstance taskReportInstance, ReportFormat format)
    at Sdl.ProjectApi.Implementation.Report.SaveAs(String targetFilePath, ReportFormat format)
    at Sdl.ProjectAutomation.FileBased.FileBasedProject.SaveTaskReportAs(Guid reportId, String path, ReportFormat reportFormat)
    at MyProgram.ProjectCreator.CreateReports(FileBasedProject project, String reportDir, List`1 trgLocales, List`1 reportIds, List`1 reportFileNames, Boolean spreadsheetReport, String projectName)
    at MyProgram.ProjectCreator.Create(List`1 docFolders, List`1 tmFiles, List`1 bilingualPaths, String projectTemplate, List`1 settingsFiles, String reportDir, String assignmentAlias, Boolean recursion, Boolean reportCrossFileRepetitions, Boolean reportInternalFuzzyMatchLeverage, Boolean keepProjectFiles, Boolean preTranslateFiles, Boolean generateTargetTranslations, Boolean compareGeneratedFiles, Boolean spreadsheetReport)
    at MyProgram.Program.Main(String[] args)
Children