Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

painful errors when copying project to another machine

Posted on 2007-10-15
7
Medium Priority
?
618 Views
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)

****************************************************************************
THE CODE THAT RUNS WHEN THE LINK IS INITIALLY CLICKED
****************************************************************************
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, ";")
        udlReader.Close()
        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
        Next

        '...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)
        frmRptPrev.ShowDialog()

    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)
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()
        '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
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    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.SuspendLayout()
        '
        'CrystalReportViewer1
        '
        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
        '
        'frmRptPreview
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(616, 517)
        Me.Controls.Add(Me.CrystalReportViewer1)
        Me.Name = "frmRptPreview"
        Me.Text = "frmRptPreview"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
        Me.ResumeLayout(False)

    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
        Else
            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
            table.ApplyLogOnInfo(tableLogonInfo)
        Next
    End Sub
End Class

**************************
Explanation
**************************
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 .....

THANKS EVERYBODY !!!!

- Travis
0
Comment
Question by:trs28
  • 3
  • 3
7 Comments
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 20079179
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.
0
 

Author Comment

by:trs28
ID: 20079311
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.
0
 
LVL 18

Expert Comment

by:UnifiedIS
ID: 20079437
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 BusinessObjects.com, you might just need the merge module
http://support.businessobjects.com/downloads/merge_modules.asp#04
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:trs28
ID: 20079685
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.
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 200 total points
ID: 20079885
You may have to delete the references to the .Net version first.

YOu may also have to navigate to the correct dlls.

mlmcc
0
 

Author Comment

by:trs28
ID: 20079985
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?
0
 
LVL 18

Accepted Solution

by:
UnifiedIS earned 1800 total points
ID: 20080146
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.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

578 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