Page 1 of 1

Exception when calling StiReport.GetReportFromAssembly(assembly)

Posted: Thu Aug 11, 2011 4:20 am
by arash_cce
When calling StiReport.GetReportFromAssembly(assembly) located in "Stimulsoft.Report.SL.dll", an InvalidCastException is raised with the following error message:
"Unable to cast object of type 'System.Object[]' to type 'Stimulsoft.Report.StiReport[]'."

I took a look at the code, and it seems that the problem is because of an invalid cast from ArrayList to StiReport[]:


public static StiReport[] GetReportsFromAssembly(Assembly assembly)
{
try
{
ArrayList list = new ArrayList();
foreach (Type type in assembly.GetTypes())
{
if (type.IsSubclassOf(typeof(StiReport)))
{
StiReport item = StiActivator.CreateObject(type) as StiReport;
item.ApplyStyles();
list.Add(item);
}
}
return (StiReport[]) list.ToArray();
}
catch
{
if (!HideExceptions)
{
throw;
}
}
return null;
}

It seems this problem only exists in silverlight version, because in the "Stimulsoft.Report.dll" assembly the cast seems to be applied correctlly:

return (StiReport[]) list.ToArray(typeof(StiReport));


Thank you in advance.


Exception when calling StiReport.GetReportFromAssembly(assembly)

Posted: Thu Aug 11, 2011 11:00 am
by Anton Lozovskiy
Hello,

The problem is fixed. The patch is available in prerelease build of on 18 August 2011.

Thank you.

Exception when calling StiReport.GetReportFromAssembly(assembly)

Posted: Fri Aug 12, 2011 11:17 pm
by arash_cce
OK, I'll check it out.
Thank you for your support.

Exception when calling StiReport.GetReportFromAssembly(assembly)

Posted: Sat Aug 13, 2011 12:16 am
by Andrew
Ok!

Let us know if you have additional questions.
Thank you.