zoukankan      html  css  js  c++  java
  • check whether the crystal report runtime is exists 检查crystalreport运行时是否存在

    1.

                Try
                    Dim rptDoc As New CrystalDecisions.CrystalReports.Engine.ReportClass()
                    Dim rptView As New CrystalDecisions.Windows.Forms.CrystalReportViewer()
                Catch ex As Exception
                    If (System.IntPtr.Size = 8) Then
                        Dim ehp As BLL2.ExecutorHelper = New BLL2.ExecutorHelper()
                        Dim path As String = ehp.Download2UnZipRpt()
                        BLL2.ExecutorHelper.ExecuteAsAdmin(path)
                    Else
                        ' leave the work for 32bit os to develop in the future
                    End If
    
                End Try

    2. more information 

    when you initialize a ReportDocument on a system without a crystal report runtime, it will thrown an error:


    ************** Exception Text **************
    System.TypeInitializationException: The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception. ---> CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: An error has occurred while attempting to load the Crystal Reports runtime. Either the Crystal Reports registry key permissions are insufficient, or the Crystal Reports runtime is not installed correctly. Please install the appropriate Crystal Reports redistributable (CRRedist*.msi) containing the correct version of the Crystal Reports runtime (x86, x64, or Itanium) required. Please go to http://www.businessobjects.com/support for more information.
    at CrystalDecisions.CrystalReports.Engine.ReportDocument.CheckForCrystalReportsRuntime()
    at CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor()
    --- End of inner exception stack trace ---
    at CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor()
    at GermanSchool.InvoiceReportForm.InvoiceReportForm_Load(Object sender, EventArgs e)
    at System.Windows.Forms.Form.OnLoad(EventArgs e)
    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.Form.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    // CrystalDecisions.CrystalReports.Engine.ReportDocument
    private static void CheckForCrystalReportsRuntime()
    {
        string pathList = Registry.LocalMachine + "\" + ReportDocument.CR_REGKEY;
        RegistryPermission registryPermission = new RegistryPermission(RegistryPermissionAccess.Read, pathList);
        registryPermission.Assert();
        RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(ReportDocument.CR_REGKEY);
        if (registryKey == null)
        {
            string @string = CREngineRes.GetString("IDS_ERROR_CR_RUNTIME_NOT_INSTALLED");
            ReportDocument.LogSCRException(@string, 4096);
            if (SystemInformation.UserInteractive)
            {
                MessageBox.Show(@string, CREngineRes.GetString("IDS_EVENTLOG_SOURCE"));
            }
            throw new LoadSaveReportException(@string, EngineExceptionErrorID.LoadingReportFailed);
        }
    }
  • 相关阅读:
    HDU 5793 A Boring Question 2016多校第六场1001
    HDU 5803 Zhu’s Math Problem 2016多校第六场1011 数位dp
    HDU 5787 K-wolf Number 2016多校第五场1007 数位dp
    HDU 5791 Two 2016多校第五场1011 LCS
    HDU 5773 The All-purpose Zero 2016多校第四场1010 LIS
    HDU 5768 Lucky7 2016多校第四场1005
    hdu 5002 Tree(LCT裸题)
    Wannafly挑战赛1 C MMSet2
    hdu 5398 GCD Tree(LCT动态维护最大生成树)
    hdu 5967 小R与手机(LCT裸题)
  • 原文地址:https://www.cnblogs.com/zyip/p/3686016.html
Copyright © 2011-2022 走看看