当窗体拖入crystalReportViewer控件并运行时一定几率会在InitializeComponent()方法中 this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();这条语句发生异常,这个异常以前从来没有碰到过,网上有人遇到过,可是没看到解决方案,我安装逐步剔除法发现原来是配置文件的问题。如果配置文件书写不正确就会发生这样的异常.
比如:
<!-- 要加载的配置文件 -->
<section name="SysInit" type="System.Configuration.NameValueSectionHandler" />
会发生异常
<configSections>
<!-- 要加载的配置文件 -->
<section name="SysInit" type="System.Configuration.NameValueSectionHandler" />
</configSections>
则不会