Reports from Assemblies

Stimulsoft Reports.NET discussion
Milton Guevara
Posts: 53
Joined: Thu Aug 21, 2008 9:28 pm
Location: Peru

Reports from Assemblies

Post by Milton Guevara »

Hello
I'm using reports in dll (assemblies) in my programs, i use the following code in VB to load the report:

factura = StiReport.GetReportFromAssembly(My.Application.Info.DirectoryPath & "\Reportes\Formatos\boleta.dll")
factura.RegData(facturaDataSet)
factura.Print(False)

When i upgrade to a new preleased, i get the following error: "Unabled to load one or more of the requested types. Retrieve the LoaderExceptions property for more information"

This is solved recreating the report as assemblie ("save reports as").
Any idea of how can i make to avoid this manual and the update is transparaente?

Thanks

Milton Guevara


Spanish
Hola
Estoy usando reportes en dll (assemblies) en mis programas, utilizo el siguiente codigo en VB para cargar el reporte:
factura = StiReport.GetReportFromAssembly(My.Application.Info.DirectoryPath & "\Reportes\Formatos\boleta.dll")
factura.RegData(facturaDataSet)
factura.Print(False)

Cuando realizo una actualización a un nuevo preleased, me aparece el siguiente error: "Unabled to load one or more of the requested types. Retrieve the LoaderExceptions property for more information"

Esto se soluciona volviendo a crear el reporte como assemblie ("save reports as").
Alguna idea de cómo puedo hacer para evitar este cambio manual y la actualización sea transparaente ?

Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Reports from Assemblies

Post by Vital »

Hello Milton,

You can use following code:

Code: Select all

StiReport report = new StiReport();
report.Load(file);

string folder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
folder = Path.Combine(folder, "Stimulsoft\\CompiledReports");
folder = Path.Combine(folder, System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().ToString());
string compiledReportFile = Path.Combine(folder, report.GetReportAssemblyCacheName());

					
if (File.Exists(compiledReportFile))
{
	report = StiReport.GetReportFromAssembly(compiledReportFile, true);
	report.RegData(dataSet);

	report.Render();
}
else
{
	report.RegData(dataSet);						
	if (!Directory.Exists(folder))Directory.CreateDirectory(folder);

	report.Compile(compiledReportFile);
			
	report.Render();
}
					
if (!report.IsStopped)
{	
	report.Show();
}
Thank you.
Milton Guevara
Posts: 53
Joined: Thu Aug 21, 2008 9:28 pm
Location: Peru

Reports from Assemblies

Post by Milton Guevara »

Vital, thank you for your answer, i have some consultations:

1. The problem reported occurs in two situations: when do i update my application to a new version and also when do i update Stimulsoft to a new version. ¿ is this code addresses both cases?

2. The folder "Stimulsoft\\CompiledReports" will keep reports compiled old, will grown indefinitely or deleted automatically?

3. When you modify a report the code also will detect the change and recompile?

Thank you

Spanish:
Vital Gracias por tu respuesta, tengo algunas consultas:

1. El problema reportado ocurre en dos situaciones: cuando yo actualiza mi aplicación a una nueva version y tambien cuando actualizo Stimulsoft a una nueva version. ¿ Este codigo soluciona ambos casos ?

2. La carpeta "Stimulsoft\\CompiledReports" mantendrá reportes compilados antiguos, ¿ crecerá de forma indefenida o se eliminan automaticamante en algun momento ?

3. Cuando modifico un reporte, ¿ el codigo detecta el cambio y recompila ?
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Reports from Assemblies

Post by Vital »

Hello Milton,
1. The problem reported occurs in two situations: when do i update my application to a new version and also when do i update Stimulsoft to a new version. ¿ is this code addresses both cases?
If you update Stimulsoft - yes, if you update your application - no. But you can add version of your application to GetReportAssemblyCacheName. For example:
GetReportAssemblyCacheName() + myVersionNumber;
2. The folder "Stimulsoft\\CompiledReports" will keep reports compiled old, will grown indefinitely or deleted automatically?
You need add code to delete old reports.
3. When you modify a report the code also will detect the change and recompile?
Yes, this code automatically create new assembly for report.

Thank you.

Milton Guevara
Posts: 53
Joined: Thu Aug 21, 2008 9:28 pm
Location: Peru

Reports from Assemblies

Post by Milton Guevara »

Vital

OK, this all clear.
Thank you for your support.

Milton
tammamkoujan
Posts: 22
Joined: Wed Oct 08, 2008 1:57 pm

Reports from Assemblies

Post by tammamkoujan »

Hi
i faced the same problem
also when i use the reports designer to create a report from business object i cannot create a data source using a business object because create new data source
show empty dialog,
and when i open a report created with the an older version of stimulsoft reports.net i cannot compile this report and it show disconnected data source .
All of that was working in the previous version.
Please advice.
tammamkoujan
Posts: 22
Joined: Wed Oct 08, 2008 1:57 pm

Reports from Assemblies

Post by tammamkoujan »

up
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Reports from Assemblies

Post by Edward »

Hello.
i faced the same problem
also when i use the reports designer to create a report from business object i cannot create a data source using a business object because create new data source
show empty dialog,
and when i open a report created with the an older version of stimulsoft reports.net i cannot compile this report and it show disconnected data source .
All of that was working in the previous version.
Please advice.
But above you can find a solution for the problem as well. If you still in doubt about possible solution, please send a sample project which illustrates the problem to support[at]stimulsoft.com for analysis and we would help you.

Thank you.
tammamkoujan
Posts: 22
Joined: Wed Oct 08, 2008 1:57 pm

Reports from Assemblies

Post by tammamkoujan »

i am talking about "when i use the reports designer to create a report from business object i cannot create a data source using a business object because create new data source
show empty dialog,
and when i open a report created with the an older version of stimulsoft reports.net i cannot compile this report and it show disconnected data source .
All of that was working in the previous version."

in an older version i was creating the reports from business object very easy now i did not know why i cannot.


Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Reports from Assemblies

Post by Vital »

Hello,

Please try to call "Synchronize" function from Report Dictionary in "Actions" menu.

Thank you.
Post Reply