原創(chuàng)|使用教程|編輯:鄭恭琳|2015-12-14 10:25:51.000|閱讀 2329 次
概述:本片文章主要介紹Stimulsoft Reports.Net開(kāi)發(fā)者在處理編譯報(bào)表時(shí)遇到的常見(jiàn)問(wèn)題及解決方案。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
< Stimulsoft Reports.Net v2015.3最新版本下載>
使用Compile方法:
C#
//編譯到文件 report.Compile("MyReport.dll"); //編譯到流 report.Compile(stream);
VB
'編譯到文件 Report.Compile("MyReport.dll") '編譯到流 Report.Compile(stream)
此外,你還可以從報(bào)表設(shè)計(jì)器將報(bào)表保存到匯編。
當(dāng)你使用StiReport.GetReportFromAssembly方法時(shí),報(bào)表被加載到每一個(gè)案例的內(nèi)存中。這在當(dāng)你從匯編加載報(bào)表需要指定附加參數(shù)時(shí)可避免:
C#
StiReport report = StiReport.GetReportFromAssembly("MyReport.dll", true);
VB
Dim Report As StiReport = StiReport.GetReportFromAssembly("MyReport.dll", True)
需記住的是在這種情況下.dll文件將被封鎖,直到應(yīng)用程序運(yùn)行起來(lái)。
在報(bào)表設(shè)計(jì)器中你可以將你的報(bào)表保存為匯編(DLL文件)。你可以通過(guò)下面的代碼在你的應(yīng)用程序中使用該類報(bào)表:
C#
StiReport report = StiReport.GetReportFromAssembly("MyReport.dll", true);
VB
Dim Report As StiReport = StiReport.GetReportFromAssembly("MyReport.dll")
你也可以在第一次訪問(wèn)時(shí)編譯你的報(bào)表,接下來(lái)就會(huì)使用第一次編譯后的版本。它的性能將會(huì)提高。
C#
string reportName = "MyReport.mrt"; string reportDllName = "MyReport.dll"; StiReport report = null; // 如果dll文件不存在 if (!File.Exists(reportDllName)) { // 加載報(bào)表定義 report = new StiReport(); report.Load(reportName); // 編譯報(bào)表,保存報(bào)表的dll版本 report.Compile(reportDllName); } else // 如果報(bào)表匯編可用 { // 使用報(bào)表匯編 report = StiReport.GetReportFromAssembly(reportDllName); }
VB
Dim ReportName As String = "MyReport.mrt" Dim ReportDllName As String = "MyReport.dll" Dim Report As StiReport = Nothing '如果dll文件不存在 If Not File.Exists(ReportDllName) Then '加載報(bào)表定義 Report = New StiReport Report.Load(ReportName) '編譯報(bào)表,保存報(bào)表的dll版本 Report.Compile(ReportDllName) Else '如果報(bào)表匯編可用 Report = StiReport.GetReportFromAssembly(ReportName) End If
兼容性可通過(guò)以下兩種方式解決:
I.在配置中寫(xiě)入bindingRedirects。示例:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Stimulsoft.Report" publicKeyToken="EBE6666CBA19647A" culture="neutral" /> <bindingRedirect oldVersion="1.30.0.0" newVersion="1.31.0.0/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Stimulsoft.Report.Export.HtmlExport" publicKeyToken="EBE6666CBA19647A" culture="neutral" /> <bindingRedirect oldVersion="1.30.0.0" newVersion="1.31.0.0"/> </dependentAssembly> [... and etc. for each new assembly ...] </assemblyBinding> </runtime> </configuration>
II.為每一個(gè)舊版本創(chuàng)建一個(gè)policy發(fā)布文件。示例:
policy.1.23.Stimulsoft.Base.dll policy.1.30.Stimulsoft.Base.dll policy.1.23.Stimulsoft.Report.dll policy.1.30.Stimulsoft.Report.dll
可以使用StiReport類的GetReportFromAssembly靜態(tài)方法實(shí)現(xiàn)。此方法返回創(chuàng)建的報(bào)告。下面是調(diào)用該方法的示例:
C#
//從匯編加載報(bào)表 StiReport report = StiReport.GetReportFromAssembly(assembly); //從文件加載報(bào)表 StiReport report = StiReport.GetReportFromAssembly("MyReport.dll"); //從流加載報(bào)表 StiReport report = StiReport.GetReportFromAssembly(stream);
VB
'從匯編加載報(bào)表 Dim Report As StiReport = StiReport.GetReportFromAssembly(assembly) '從文件加載報(bào)表 Dim Report As StiReport = StiReport.GetReportFromAssembly("MyReport.dll") '從流加載報(bào)表 Dim Report As StiReport = StiReport.GetReportFromAssembly(stream)
購(gòu)買最新正版授權(quán)!""
慧都年終盛典火爆開(kāi)啟,一年僅一次的最強(qiáng)促銷,破冰鉅惠不容錯(cuò)過(guò)!!優(yōu)惠詳情點(diǎn)擊查看>>
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn