为什么在从 C# 导出 Telerik 报告时不允许 ObjectDataSource 组件使用该程序集
Why The assembly is not permitted to be used by an ObjectDataSource component when exporting Telerik Report from C#
处理 Table 时发生错误 'table2': ObjectDataSource 组件不允许使用程序集 "AssemblyName.Context, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"。请将其包含在应用程序配置文件的 Telerik.Reporting 配置部分的 AssemblyReferences 元素中。
我正在使用以下代码导出 pdf 报告。
public static System.IO.Stream GerRep(List<EquipmentSearchResult> list)
{
EquipmentExportReportT report = new EquipmentExportReportT();
report.ReportParameters["BaseLocationName"].Value = "MyTest";
//report.DataSource = list;
ReportProcessor reportProcessor = new ReportProcessor();
// set any deviceInfo settings if necessary
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
Telerik.Reporting.TypeReportSource typeReportSource = new Telerik.Reporting.TypeReportSource();
// reportName is the Assembly Qualified Name of the report
typeReportSource.TypeName = typeof(EquipmentExportReportT).AssemblyQualifiedName;
RenderingResult result = reportProcessor.RenderReport("XLS", typeReportSource, deviceInfo);
string fileName = result.DocumentName + "." + result.Extension;
string path = System.IO.Path.GetTempPath();
string filePath = System.IO.Path.Combine(path, fileName);
using (FileStream fs = new FileStream(filePath, System.IO.FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
MemoryStream ms = new MemoryStream(result.DocumentBytes);
ms.Position = 0;
return ms;
}
这是配置问题,您需要在 web.config 文件上应用一些设置。
在这种情况下,需要修改应用程序配置文件,并且需要按以下方式将程序集的名称添加到 AssemblyReferences 元素内容中的新节点中:
<configuration>
<configSections>
<section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<Telerik.Reporting>
<assemblyReferences>
<add name="yourAssemblyName"/>
</assemblyReferences>
</Telerik.Reporting>
</configuration>
希望这能解决您的问题。干杯:)
处理 Table 时发生错误 'table2': ObjectDataSource 组件不允许使用程序集 "AssemblyName.Context, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"。请将其包含在应用程序配置文件的 Telerik.Reporting 配置部分的 AssemblyReferences 元素中。
我正在使用以下代码导出 pdf 报告。
public static System.IO.Stream GerRep(List<EquipmentSearchResult> list)
{
EquipmentExportReportT report = new EquipmentExportReportT();
report.ReportParameters["BaseLocationName"].Value = "MyTest";
//report.DataSource = list;
ReportProcessor reportProcessor = new ReportProcessor();
// set any deviceInfo settings if necessary
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
Telerik.Reporting.TypeReportSource typeReportSource = new Telerik.Reporting.TypeReportSource();
// reportName is the Assembly Qualified Name of the report
typeReportSource.TypeName = typeof(EquipmentExportReportT).AssemblyQualifiedName;
RenderingResult result = reportProcessor.RenderReport("XLS", typeReportSource, deviceInfo);
string fileName = result.DocumentName + "." + result.Extension;
string path = System.IO.Path.GetTempPath();
string filePath = System.IO.Path.Combine(path, fileName);
using (FileStream fs = new FileStream(filePath, System.IO.FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
MemoryStream ms = new MemoryStream(result.DocumentBytes);
ms.Position = 0;
return ms;
}
这是配置问题,您需要在 web.config 文件上应用一些设置。
在这种情况下,需要修改应用程序配置文件,并且需要按以下方式将程序集的名称添加到 AssemblyReferences 元素内容中的新节点中:
<configuration>
<configSections>
<section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<Telerik.Reporting>
<assemblyReferences>
<add name="yourAssemblyName"/>
</assemblyReferences>
</Telerik.Reporting>
</configuration>
希望这能解决您的问题。干杯:)