如何获取内部文件夹的路径?
How to get the path of an internal folder?
我在 WinForms C# 中有一个项目,我创建了一个内部文件夹 reports
来添加我的 RDLC 报告,它在我开发时工作正常,问题是当我创建 Setup
使用 InstallShield Limited Edition
安装应用程序,因为在安装应用程序后我尝试执行报告并抛出异常而不显示它。
开发 我认为它的工作原理是因为可执行文件是在 Debug\bin
中创建的,我使用 @..\..\reports\MyReport.rdlc
获取路径但是在创建 Setup
并将应用程序安装到此文件夹 reports
不存在。
我该如何解决这个问题?
打开我做的报告
reportViewer.LocalReport.ReportPath = @"..\..\reports\RelContasPagar.rdlc";
异常
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
Microsoft.Reporting.WinForms.LocalProcessingException: Ocorreu um erro durante o processamento de relatórios local. ---> System.ApplicationException: A definição do relatório 'RelFluxoCaixa' não foi especificada ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\reports\RelFluxoCaixa.rdlc'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Microsoft.ReportingServices.StandalonePreviewStore.GetReportDefinition(PreviewItemContext itemContext)
--- End of inner exception stack trace ---
at Microsoft.ReportingServices.StandalonePreviewStore.GetReportDefinition(PreviewItemContext itemContext)
at Microsoft.Reporting.LocalService.GetCompiledReport(PreviewItemContext itemContext, Boolean rebuild, ControlSnapshot& snapshot)
at Microsoft.Reporting.LocalService.CompileReport()
at Microsoft.Reporting.LocalService.Microsoft.Reporting.ILocalProcessingHost.CompileReport()
at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
--- End of inner exception stack trace ---
at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)
at ControleDeVendas.reports.ViewReport.geraRelFluxoCaixa()
at ControleDeVendas.reports.ViewReport.executeTipoRelatorio()
at ControleDeVendas.reports.ViewReport.ViewReport_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
ControleDeVendas
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files%20(x86)/Iguana%20Sistemas/Controle%20de%20Vendas/ControleDeVendas.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
NHibernate
Assembly Version: 4.0.0.4000
Win32 Version: 4.0.4.4000
CodeBase: file:///C:/Program%20Files%20(x86)/Iguana%20Sistemas/Controle%20de%20Vendas/NHibernate.DLL
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
FluentNHibernate
Assembly Version: 2.0.3.0
Win32 Version: 2.0.3.0
CodeBase: file:///C:/Program%20Files%20(x86)/Iguana%20Sistemas/Controle%20de%20Vendas/FluentNHibernate.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.GeneratedCode
Assembly Version: 1.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Xml.Linq
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
MySql.Data
Assembly Version: 6.9.8.0
Win32 Version: 6.9.8.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/MySql.Data/v4.0_6.9.8.0__c5687fc88969c44d/MySql.Data.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Management
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Management.dll
----------------------------------------
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
Microsoft.ReportViewer.WinForms
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.ReportViewer.WinForms/11.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.WinForms.dll
----------------------------------------
Microsoft.ReportViewer.WinForms.resources
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.ReportViewer.WinForms.resources/11.0.0.0_pt_89845dcd8080cc91/Microsoft.ReportViewer.WinForms.resources.dll
----------------------------------------
Microsoft.ReportViewer.Common
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.ReportViewer.Common/11.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.Common.dll
----------------------------------------
Microsoft.ReportViewer.Common.resources
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.ReportViewer.Common.resources/11.0.0.0_pt_89845dcd8080cc91/Microsoft.ReportViewer.Common.resources.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
内部文件夹
几天前,我在 Windows Store App 中遇到了同样的问题,我只是用正斜杠(即“/”)替换了反斜杠,即“\”。
示例:-
@../../reports/MyReport.rdlc
据我研究,在某些情况下反斜杠用于 linux。
~/reports/MyReport.rdlc
~ 将获得 root
解决方案取决于您项目中 rdlc
个文件的 Build Action
属性 个:
构建操作是嵌入式资源
如果Build Action
是Embedded Resource
,则不需要使用文件路径。这些报告已嵌入到您的可执行文件中,您可以这样使用它们:
reportViewer1.LocalReport.ReportEmbeddedResource = "Sample.Reports.Report1.rdlc";
这是将报告添加到项目时的默认行为。 Visual Studio 将构建操作设置为嵌入资源。
构建操作是内容并且复制到输出目录是始终复制
如果 Build Action
id Content
和 Copy To Output Directory
是 Copy Always
那么您的文件将在项目的 bin 文件夹下找到有解决方案。所以你可以这样找到它们:
var path = System.IO.Path.Combine(Application.StartupPath, "Reports", "Report1.rdlc");
reportViewer1.LocalReport.ReportPath = path;
备注
Sample.Reports.Report1.rdlc
中的第一个选项中,Sample
是命名空间,Reports
是文件夹名称,Report1.rdlc
是报告名称。
- 如果您使用了第二个选项,请确保您的安装程序制作工具将这些文件复制到
\Reports
文件夹下的输出目录中。
我在 WinForms C# 中有一个项目,我创建了一个内部文件夹 reports
来添加我的 RDLC 报告,它在我开发时工作正常,问题是当我创建 Setup
使用 InstallShield Limited Edition
安装应用程序,因为在安装应用程序后我尝试执行报告并抛出异常而不显示它。
开发 我认为它的工作原理是因为可执行文件是在 Debug\bin
中创建的,我使用 @..\..\reports\MyReport.rdlc
获取路径但是在创建 Setup
并将应用程序安装到此文件夹 reports
不存在。
我该如何解决这个问题?
打开我做的报告
reportViewer.LocalReport.ReportPath = @"..\..\reports\RelContasPagar.rdlc";
异常
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
Microsoft.Reporting.WinForms.LocalProcessingException: Ocorreu um erro durante o processamento de relatórios local. ---> System.ApplicationException: A definição do relatório 'RelFluxoCaixa' não foi especificada ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\reports\RelFluxoCaixa.rdlc'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Microsoft.ReportingServices.StandalonePreviewStore.GetReportDefinition(PreviewItemContext itemContext)
--- End of inner exception stack trace ---
at Microsoft.ReportingServices.StandalonePreviewStore.GetReportDefinition(PreviewItemContext itemContext)
at Microsoft.Reporting.LocalService.GetCompiledReport(PreviewItemContext itemContext, Boolean rebuild, ControlSnapshot& snapshot)
at Microsoft.Reporting.LocalService.CompileReport()
at Microsoft.Reporting.LocalService.Microsoft.Reporting.ILocalProcessingHost.CompileReport()
at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
--- End of inner exception stack trace ---
at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)
at ControleDeVendas.reports.ViewReport.geraRelFluxoCaixa()
at ControleDeVendas.reports.ViewReport.executeTipoRelatorio()
at ControleDeVendas.reports.ViewReport.ViewReport_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
ControleDeVendas
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files%20(x86)/Iguana%20Sistemas/Controle%20de%20Vendas/ControleDeVendas.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
NHibernate
Assembly Version: 4.0.0.4000
Win32 Version: 4.0.4.4000
CodeBase: file:///C:/Program%20Files%20(x86)/Iguana%20Sistemas/Controle%20de%20Vendas/NHibernate.DLL
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
FluentNHibernate
Assembly Version: 2.0.3.0
Win32 Version: 2.0.3.0
CodeBase: file:///C:/Program%20Files%20(x86)/Iguana%20Sistemas/Controle%20de%20Vendas/FluentNHibernate.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.GeneratedCode
Assembly Version: 1.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Xml.Linq
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
MySql.Data
Assembly Version: 6.9.8.0
Win32 Version: 6.9.8.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/MySql.Data/v4.0_6.9.8.0__c5687fc88969c44d/MySql.Data.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Management
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Management.dll
----------------------------------------
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
Microsoft.ReportViewer.WinForms
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.ReportViewer.WinForms/11.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.WinForms.dll
----------------------------------------
Microsoft.ReportViewer.WinForms.resources
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.ReportViewer.WinForms.resources/11.0.0.0_pt_89845dcd8080cc91/Microsoft.ReportViewer.WinForms.resources.dll
----------------------------------------
Microsoft.ReportViewer.Common
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.ReportViewer.Common/11.0.0.0__89845dcd8080cc91/Microsoft.ReportViewer.Common.dll
----------------------------------------
Microsoft.ReportViewer.Common.resources
Assembly Version: 11.0.0.0
Win32 Version: 11.0.3366.16 ((SQL11_SP1_RS_Dev12-RTM).130829-0516 )
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.ReportViewer.Common.resources/11.0.0.0_pt_89845dcd8080cc91/Microsoft.ReportViewer.Common.resources.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
内部文件夹
几天前,我在 Windows Store App 中遇到了同样的问题,我只是用正斜杠(即“/”)替换了反斜杠,即“\”。 示例:-
@../../reports/MyReport.rdlc
据我研究,在某些情况下反斜杠用于 linux。
~/reports/MyReport.rdlc
~ 将获得 root
解决方案取决于您项目中 rdlc
个文件的 Build Action
属性 个:
构建操作是嵌入式资源
如果
Build Action
是Embedded Resource
,则不需要使用文件路径。这些报告已嵌入到您的可执行文件中,您可以这样使用它们:reportViewer1.LocalReport.ReportEmbeddedResource = "Sample.Reports.Report1.rdlc";
这是将报告添加到项目时的默认行为。 Visual Studio 将构建操作设置为嵌入资源。
构建操作是内容并且复制到输出目录是始终复制
如果
Build Action
idContent
和Copy To Output Directory
是Copy Always
那么您的文件将在项目的 bin 文件夹下找到有解决方案。所以你可以这样找到它们:var path = System.IO.Path.Combine(Application.StartupPath, "Reports", "Report1.rdlc"); reportViewer1.LocalReport.ReportPath = path;
备注
Sample.Reports.Report1.rdlc
中的第一个选项中,Sample
是命名空间,Reports
是文件夹名称,Report1.rdlc
是报告名称。- 如果您使用了第二个选项,请确保您的安装程序制作工具将这些文件复制到
\Reports
文件夹下的输出目录中。