painful errors when copying project to another machine

Posted on 2007-10-15
Last Modified: 2013-11-26
I took over a project that was being done in VB.NET and I'm having one hell of a time getting it off of the machine it was initially created on.  There is a DevExpress component installed, and the Crystal Reports XI Developer Ed. is installed as well.  

For some reason, on my machine, when I try to do a build, I start having trouble with the Crystal Reports components.  I'm going to list the code that works fine on the original machine, but then i'll also point out which part is causing the issue too ....

(by the way, the report filename is ReportStoredChecks.rpt)

Private Sub nbiStoredChecks_LinkClicked(ByVal sender As Object, ByVal e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles nbiStoredChecks.LinkClicked
        Dim reportname As String = "ReportStoredChecks"
        '....pulls out the udl file data so it can be passed to CR at runtime
        Dim udlReader As StreamReader = New StreamReader("Conn.udl")
        Dim udlLines() As String = Split(udlReader.ReadToEnd, ";")
        Dim endofline, startofline As String
        Dim provider, password, userid, catalog, server, intSecurity As String
        Dim udlValues() As String
        Dim i As Integer
        For i = 1 To udlLines.GetUpperBound(0)
            startofline = udlLines(i).Substring(0, udlLines(i).IndexOf("="))
            endofline = udlLines(i).Substring(udlLines(i).IndexOf("=") + 1, udlLines(i).Length - udlLines(i).IndexOf("=") - 1)
            If endofline.Substring(endofline.Length - 2) = vbCrLf Then
                endofline = endofline.Remove(endofline.LastIndexOf(vbCrLf), 2)
            End If
            If startofline = "Password" Then
                password = endofline
            End If
            If startofline = "User ID" Then
                userid = endofline
            End If
            If startofline = "Data Source" Then
                server = endofline
            End If
            If startofline = "Initial Catalog" Then
                catalog = endofline
            End If
            If startofline = "Integrated Security" Then
                intSecurity = endofline
            End If

        '...packages all values needed into one ArrayList to simplify DBCredentials object parameter list
        Dim alDBCreds As New ArrayList(New String() {server, catalog, userid, password, intSecurity})
        '...send udl values to DBCredentials object for db authentication
        Dim dbCreds As DBCredentials = New DBCredentials(alDBCreds)

        Dim frmRptPrev As frmRptPreview = New frmRptPreview(reportname, dbCreds)

    End Sub

HERE IS THE "frmRptPrev" class
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class frmRptPreview
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New(ByRef typedRptClass As String, ByRef dbCreds As DBCredentials)

        'This call is required by the Windows Form Designer.
        'Add any initialization after the InitializeComponent() call
        ConfigureReport(typedRptClass, dbCreds)
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
            End If
        End If
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.CrystalReportViewer1 = New CrystalDecisions.Windows.Forms.CrystalReportViewer
        Me.CrystalReportViewer1.ActiveViewIndex = -1
        Me.CrystalReportViewer1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.CrystalReportViewer1.DisplayGroupTree = False
        Me.CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
        Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
        Me.CrystalReportViewer1.ReportSource = Nothing
        Me.CrystalReportViewer1.Size = New System.Drawing.Size(616, 520)
        Me.CrystalReportViewer1.TabIndex = 0
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(616, 517)
        Me.Name = "frmRptPreview"
        Me.Text = "frmRptPreview"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized

    End Sub

#End Region

    '<STAThread()> _
    'Shared Sub Main()
    '  Application.Run(New frmRptPreview(New DBCredentials))
    'End Sub

    '   This class only needs the name of the report file (without the extention)
    '   and a DBCredentials object passed to it for it to create all the report objects and
    '   authenticate to the server properly.

    Private Sub ConfigureReport(ByRef typedRptClass As String, ByRef dbCredentials As DBCredentials)
        Dim theReport As ReportDocument = New ReportDocument
        theReport.Load(Application.StartupPath + "\" + typedRptClass + ".rpt")

        Dim connectionInfo As ConnectionInfo = New ConnectionInfo
        connectionInfo.ServerName = DBCredentials.GetServer()
        connectionInfo.DatabaseName = DBCredentials.GetCatalog()
        If DBCredentials.GetISecurity() = True Then
            connectionInfo.AllowCustomConnection = True
            connectionInfo.Type = ConnectionInfoType.SQL
            connectionInfo.IntegratedSecurity = True
            connectionInfo.UserID = DBCredentials.GetUserID()
            connectionInfo.Password = DBCredentials.GetPassword()
        End If

        SetReportDBLogon(connectionInfo, theReport)
        CrystalReportViewer1.ReportSource = theReport
    End Sub

HERE IS THE "SetReportDBLogon" sub (part of frmRptPrev)
    Private Sub SetReportDBLogon(ByVal connectionInfo As ConnectionInfo, ByVal reportDoc As ReportDocument)
        Dim tables As Tables = reportDoc.Database.Tables
        For Each table As Table In tables
            Dim tableLogonInfo As TableLogOnInfo = table.LogOnInfo
            tableLogonInfo.ConnectionInfo = connectionInfo
    End Sub
End Class

The problem occurs here from what I gather...

If DBCredentials.GetISecurity() = True Then
            connectionInfo.AllowCustomConnection = True                 <-----------
            connectionInfo.Type = ConnectionInfoType.SQL                <-----------
            connectionInfo.IntegratedSecurity = True                           <-----------

AllowCustomConnection, ConnectionInfoType.SQL, and Integrated Security are not recognized!!   It's almost as if Visual Studio is using components from a built-in, but older version of Crystal Reports and not   the CRXI components that I'm trying to use ... The thing is, Visual Studio was installed AFTER CRXI, but I went back through and reinstalled it, thinking that might be able to take care of updating the Visual Studio components ...but with no luck

Here are the actual error messages:
'AllowCustomConnection' is not a member of 'CrystalDecisions.Shared.ConnectionInfo'.
'Type' is not a member of 'CrystalDecisions.Shared.ConnectionInfo'.
Name 'ConnectionInfoType' is not declared.
'IntegratedSecurity' is not a member of 'CrystalDecisions.Shared.ConnectionInfo'.

Again, this is the exact same code that works quite well on the original machine, so any help is GREATLY appreciated!!!    

Also, two other quick questions:  1 - Should the SetReportDBLogon sub actually be a function?!?  I'm not from the VB world & am just getting used to it, but I still haven't figured out the reason to use a "sub" in place of a function and vice versa.   2 - When first ran, it takes a few moments to create the report and apply the database credentials to each of the tables .... is there any way I can speed this up a little?!?!?!   In other words, are there any obvious bottlenecks in my code or is the delay just one I'm going to have to deal with .....


- Travis
Question by:trs28
    LVL 18

    Expert Comment

    For the crystal problems, check the crystal references you have in the project.  They are most likely a different version.  
    Functions return a result, subs don't--no reason to change
    To speed up the first run, you can try to set the security beforehand somehow or use a splash screen to minimize the perecieved delay.

    Author Comment

    Sounds perfectly logical to me!   ....but tell me, how do I find where I can check the Crystal references?  I'm from the Borland world, so needless to say, finding stuff in Visual Studio can be difficult sometimes.
    LVL 18

    Expert Comment

    Click on the crystal references (they show in your solution explorer) and look at the properties window for each one.  The path and version can be compared on each machine.  Check out the downloads on, you might just need the merge module

    Author Comment

    well i can see there's a difference between the versions.... the working one lists, in the about box, crystal reports version 11 ...and the other one lists crystal reports for .net studio     ...but like i said, i reinstalled CRXI after I installed VS on the machine i'm having trouble with (made sure to do the registration stuff too) ....but that didn't seem to change anything .... how can I get VS to take/use the correct version?  

    By the way, the Properties windows are identical ....and neither have any sort of version number.  Like I said, I had to get that from the About box.
    LVL 100

    Assisted Solution

    You may have to delete the references to the .Net version first.

    YOu may also have to navigate to the correct dlls.


    Author Comment

    the file is correct ... i already deleted it and re-added it ... and i have no idea what you're referring to in regards to the DLLs .... i know what you mean, but i had trouble finding the version of CR at first.   I don't stand a chance selecting individual DLLs without any help.

    Also, is there any performance impact when using the report as an embedded report? ... my other options are "compile" and "content"  ... i'm seeing this in the report properties under the "Advanced" section under the "Build Action" property.  Would i be better off doing it a different way?
    LVL 18

    Accepted Solution

    The crystal references in your solution are pointers to dll files.  I'm looking at a VS2005 solution and the CrystalDecisions.shared reference is C:\Program Files\Common Files\Business Objects\2.7\Managed\CrystalDecisions.Shared.dll

    You should right-click and remove the references you currently have and then add the correct ones.  
    On the add reference dialog, you should see the crystaldecisions dlls under the .net tab.  If not, you can browse to the file location.  
    Try searching your computer for crystaldecisions.shared.dll.  If you find the file you can further compare the versions through windows explorer.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now