C# C程序继续运行,尽管没有错误

C# C程序继续运行,尽管没有错误,c#,crystal-reports,C#,Crystal Reports,我在一个项目中工作,我应该提供一个crystal reports RPT文件作为输入,并获取该报告的属性 我在加载报表时遇到了一个问题,所以我使用了isLoaded函数来检查报表是否已加载 我使用了以下代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using Sy

我在一个项目中工作,我应该提供一个crystal reports RPT文件作为输入,并获取该报告的属性

我在加载报表时遇到了一个问题,所以我使用了isLoaded函数来检查报表是否已加载

我使用了以下代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

namespace sampleretreival
{
    public partial class Form1 : Form
    {
        public string flName;
        public Form1()
        {
            InitializeComponent();
            Retrieve.Enabled = false;
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstFiles.SelectedItems.Count > 0)
            {
                Retrieve.Enabled = true;
            }
            else
            {
                Retrieve.Enabled = false;
            }
        }

        private void Browse_Click(object sender, EventArgs e)
        {
            openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Multiselect = false;
            openFileDialog1.Filter = "Crystal Report Files | *.rpt";
            openFileDialog1.ShowDialog();
            flName = openFileDialog1.FileName;

            if (flName.Length != 0)
            {
                lstFiles.Items.Insert(0, flName);
                Retrieve.Enabled = true;
            }
            else
            {
                MessageBox.Show("Please select the crystal report files for analysis.", "SAMPLE", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Browse.Focus();
            }
        }

        private void Retrieve_Click(object sender, EventArgs e)
        {
            int a=1;
            ReportDocument rpt = new ReportDocument();
            rpt.Load(flName);
            int count = 5;

            if (rpt.IsLoaded)
            {
                MessageBox.Show(count.ToString());
            }
            else
            {
                MessageBox.Show(a.ToString());
            }
        }
    }
}

编译后,我单击浏览按钮从磁盘中选择报告,但当我单击检索按钮时,程序继续运行。我没有收到任何输出或任何错误。

您是否尝试在调试器中单步执行代码?检索按钮是否连接到检索单击方法?你是否双击了“检索”按钮并让Visual Studio为你创建了事件处理程序?@Tim Yup我也尝试了tat…但在我单击“检索”按钮后,它将一事无成。@KarlAnderson是的,我已经像tat oly一样完成了。请仔细检查你的代码并告诉我们,当你到达“检索”\u click时会发生什么,我有这种感觉,要么您没有到达该方法,要么flName在该点为空