This section is specifically for Bold Reports® version less than
3.x
. If you are using a higher version of Bold Reports®, recommend you to embed the VB code directly in the report itself, as VBCodeProvider is now available in the .NET Core platform.
Custom code in a report allows to include new custom constants, variables, functions, or subroutines. As the VBCodeProvider is not available in .NET Core platform, report with custom codes requires additional settings to enable this feature. This section describes the steps required to use custom codes with Report Viewer.
namespace BoldReports.Processing.Helper
{
public static class Code
{
public static string PrintHelloWorld()
{
return "Hello World";
}
}
}
If you have created the custom code class, then you need to add the assemblies in the list with what you have used in your application to Report Viewer as shown in following code example.
In our Report Viewer application, assemblies needs to be added before calling the OnReportLoaded method.
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
string basePath = _hostingEnvironment.WebRootPath;
reportOption.ReportModel.ProcessingMode = ProcessingMode.Local;
FileStream inputStream = new FileStream(basePath + @"\Resources\Product List.rdlc", FileMode.Open, FileAccess.Read);
reportOption.ReportModel.Stream = inputStream;
reportOption.ReportModel.Assemblies.Add(this.GetType().GetTypeInfo().Assembly);
}