Exception when calling StiReport.GetReportFromAssembly(assembly)

Stimulsoft Reports.Silverlight discussion
Locked
arash_cce
Posts: 4
Joined: Wed Aug 10, 2011 5:48 am

Exception when calling StiReport.GetReportFromAssembly(assembly)

Post 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.

Anton Lozovskiy
Posts: 135
Joined: Tue Aug 11, 2009 9:38 am

Exception when calling StiReport.GetReportFromAssembly(assembly)

Post by Anton Lozovskiy »

Hello,

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

Thank you.
arash_cce
Posts: 4
Joined: Wed Aug 10, 2011 5:48 am

Exception when calling StiReport.GetReportFromAssembly(assembly)

Post by arash_cce »

OK, I'll check it out.
Thank you for your support.
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Exception when calling StiReport.GetReportFromAssembly(assembly)

Post by Andrew »

Ok!

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