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
  • I have the same error when I tried to use the method "SaveTaskReportAs()" to create Excel-Reports for three languages after analyzing them.

    The error seems to happen randomly. Sometimes at the first language, sometimes at third, sometimes not at all.

    Could you find a solution for this?

    I think I could work around this by creating a new object with constructor "FileBasedProject(string)" just before calling my method which does analyzing and saving reports.

    Before that I just used the return value of project that I created before with constructor "FileBasedProject(ProjectInfo, ProjectTemplateReference)".

    I have no idea why this makes a difference and I only tested it with a small test project. But at a first glance it seems to work for me.

    I am using Studio 2019 SR2 btw.

Reply
  • I have the same error when I tried to use the method "SaveTaskReportAs()" to create Excel-Reports for three languages after analyzing them.

    The error seems to happen randomly. Sometimes at the first language, sometimes at third, sometimes not at all.

    Could you find a solution for this?

    I think I could work around this by creating a new object with constructor "FileBasedProject(string)" just before calling my method which does analyzing and saving reports.

    Before that I just used the return value of project that I created before with constructor "FileBasedProject(ProjectInfo, ProjectTemplateReference)".

    I have no idea why this makes a difference and I only tested it with a small test project. But at a first glance it seems to work for me.

    I am using Studio 2019 SR2 btw.

Children