【问题标题】:vb.net Desktop Application not running on a client machine after installation安装后 vb.net 桌面应用程序未在客户端计算机上运行
【发布时间】:2021-08-30 09:15:34
【问题描述】:

我已经使用 sql server 数据库和水晶报表在 vb.net 中创建了一个应用程序,然后我使用 Visual Studio 2015 安装程序扩展创建了安装文件,并将该项目安装在我开发该应用程序的计算机上并且运行良好.当我在客户端计算机上安装时,问题就开始了,应用程序甚至没有在客户端计算机上启动,我已经在客户端计算机上安装了所需的 .netFramework 和水晶报告运行时间引擎,但应用程序仍然没有启动。

我的启动表单上有一个后台工作人员,并且在表单加载时测试了连接。如果连接成功,应用程序会从数据库中的表中创建一个水晶报表,如果连接不成功,应用程序会加载配置表单以手动配置连接字符串,并且会显示一个消息框,显示发生了异常。

下面是代码

Imports System.ComponentModel
Imports System.Data.SqlClient

Public Class loader
Dim connection As SqlConnection

  Private Sub loader_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       
        BackgroundWorker1.RunWorkerAsync()
       
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        If BackgroundWorker1.CancellationPending Then
            e.Cancel = True
        Else
            ShowPanel([Panel2])
            LoaderReportLoading([CrystalReportViewer1])
        End If

    End Sub

    Delegate Sub LoadRpt(ByVal [crv] As Object)
    Delegate Sub SetPanelVisible(ByVal [panel] As Panel)

    Private Sub LoaderReportLoading(ByVal [crv] As Object)                     'use the same delegate LoadRpt 
        Try
            If My.Settings.connection = "" Then
                server_configuration.ShowDialog()
            Else
                connection = New SqlConnection(My.Settings.connection)
                connection.Open()
                Dim CoTable As New DataTable
                Using command As New SqlCommand("SELECT * FROM COMPANY", connection)
                    Dim adapter As New SqlDataAdapter(command)
                    adapter.Fill(CoTable)
                End Using
                Dim rep As New loaderReport
                rep.Database.Tables("COMPANY").SetDataSource(CoTable)

                If [crv].InvokeRequired Then
                    Dim myDelegate As New LoadRpt(AddressOf LoaderReportLoading)

                    Me.Invoke(myDelegate, New Object() {crv})

                Else
                    [crv].ReportSource = rep
                End If
                connection.Close()
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message, "The following Error Occured While Connecting to the database")

            server_configuration.ShowDialog()
        End Try
    End Sub
    Private Sub ShowPanel(ByVal [panel] As Panel)
        If [panel].InvokeRequired Then
            Dim myDelegate As New SetPanelVisible(AddressOf ShowPanel)

            Me.Invoke(myDelegate, New Object() {panel})

        Else
            [panel].Visible = True
        End If
    End Sub

End Class

我对使用 Windows 事件日志一无所知,这是我要部署的第一个桌面应用程序。

【问题讨论】:

  • 你内置了什么样的日志记录?您如何指定 sql 连接,您的客户端计算机上是否有可用的 sql 实例。 Windows 事件日志中有任何内容吗?
  • 在客户端机器上指定了 sqlconnection,我只使用消息框来显示错误。
  • @Seru 发生错误时,您在消息框中显示什么?也许您可以使用应用程序中适当的启动代码更新您的问题,以便我们可以看到潜在的问题点
  • 好的thanx让我更新问题并在我的启动表单中添加一些代码
  • 除了数据库引擎,确切地知道你得到的异常是什么仍然会有所帮助。实际上还没有尝试过您的代码,但是您实现该后台工作人员的方式似乎过于复杂,而且我什至不确定它是否会按您的预期工作,因为它看起来正在尝试做 UI 的东西.

标签: vb.net crystal-reports sql-server-2014


【解决方案1】:

在我的系统上实现登录后终于得到了错误。错误与水晶报告的运行时引擎有关。我将水晶报告的版本从 SP30 更改为 SP26,现在一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多