Link to home
Create AccountLog in
Avatar of VITIX
VITIX

asked on

Cant Use VS 2005 Crystal Reports in VS 2008?

I am converting a VB.Net application written in VS 2005 to run in C# using VS 2008. I have both VS 2005 and VS 2008 installed on my XP Pro machine. I have my VS 2008 options set to target the .Net 3.5 framework. I have already installed both the VS service pack 1 and the service pack for Crystal Reports Basic 2008.

The existing application includes about 50 reports that were created in VS 2005. When I run the old app in VS 2005 debug, everything works fine. The reports are using xsd data sources and runtime parameters to pull data from SQL server. They do exactly what they are supposed to do when I run the app in VS 2005 VB.

When I run in C# VS 2008 all I get is a C++ memory exception. If I try to view or watch the exception objects, all I get is a long list of "cannot interpret because a native frame is on top of the stack" or something like that. This exception comes up before the report ever tries to query any data. If I try to set a variable to the report tables, I get an error because there are no tables, no database, nothing. I only get that message about the native frame on top of the stack.

The VS 2008 code is running against a new server, but even if I use the old connection strings and the old server and the old database, the reports still will not run in VS 2008. The VS 2005 code and reports all runs against the old server and old database.

Some of the reports will display data correctly in design mode preview, while others display some default stuff like colors names and data types. Why do they display correct data in design mode, but then wont work in runtime? Is this a compatibility issue? A framework version issue? Am I going to have to recreate these reports from scratch using the VS 2008 designer? Or is there a way to "import" them and "upgrade" them using the existing reports created in VS 2005?
SOLUTION
Avatar of williamcampbell
williamcampbell
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of VITIX
VITIX

ASKER

Not sure what you mean by "try erasing everything"...... but I have closed and reopened and cleaned and rebuilt and it makes no difference. Building a new report from scratch in VS 2008 gives me the same error. I will post the exact error messages when I get back to the desk.

The errors happen as soon as the ReportDocument object is set to a new instance of the report class. For example, I have MyReport.rpt and MyReport.cs files included in the project. I do something like this:

ReportDocument crMyReport = new ReportDocument();
crMyReport = MyReport();

(I dont have the exact code here in front of me right now, sorry)
The constructor in MyReport.cs is empty. Those two lines work fine, but then the next line I try setting MyTables = crMyReport.Tables and that's when the exceptions start. It's as if the report class never gets instantiated properly, there is no default table or database or parameters or anything in the report object. When I mouse over it, every property of the report object has that line about "Cannot interpret because a native frame is on top of the stack."

Is there something about using xsd files I am missing? I've never used them before, but the guy who wrote the original code and reports using VB and VS 2005 has a data source with xsd and xss files for each report. I assume the reports work in the designer because they are not using the C# code to run. I am not glued to the xml data source thing either. I can change the database methods if necessary, but I dont think that's the problem. I dont think the report object is ever getting to the point where it talks to the SQL server. The exceptions come up before that ever happens.

I have the option to try installing the full version of Crystal Reports XI. I also have thought about transferring the new C# code back to VS 2005 just to see if it runs correctly there, since our main goal is to switch over to C#, not necessarily to be using VS 2008. If I knew how to use SQL Reporting Services I would be tempted to abandon Crystal.
Avatar of VITIX

ASKER

The exact runtime error is:

First-chance exception at 0x7c812aeb (kernel32.dll) in UHHM.exe: Microsoft C++ exception: _com_error at memory location 0x0012d5f4..



While in break mode, when I mouse over the report object I created, every property, memeber, etc of the report object says this:

"Cannot evaluate expression because a native frame is on top of the call stack."


It's as if the code does not know the report exists. If I run and break in VS2005, then I can mouse over the report object and I can see the default table, the names and values of the parameters, the names of the report fields, etc.....
Avatar of VITIX

ASKER

I just encountered this error while trying to run a simple Crystal Report page in VS 2005. The page was created by another programmer using VS 2005, and it runs just fine on his machine. (He does not have VS 2005 and VS 2008 installed on the same machine.)


"Unable to find the report in the manifest resources. Please build the project and try again."  



Could all of my problems stem from having both versions of VS on one machine?
Avatar of VITIX

ASKER

I have now uninstalled VS 2005, and re-installed VS 2008, but I still get the same errors. The same code same reports runs fine on the other programmer's machine. The only difference is he has never had both versions of VS installed on his machine, he only installed VS 2008 on his.

This code instantiates the report object:

        ReportDocument Reportname = new ReportDocument();
        Reportname = new TransactionList();
        MessageBox.Show(Reportname.DataDefinition.ToString());

and I get the C++ error (given above) on the message box line, as if the report does not actually exist.




The class code associated with the report is:

namespace ABCD {

    using System;
    using System.ComponentModel;
    using CrystalDecisions.Shared;
    using CrystalDecisions.ReportSource;
    using CrystalDecisions.CrystalReports.Engine;
   
   
    public class TransactionList : ReportClass {
       
        public TransactionList() {
        }
       
        public override string ResourceName {
            get {
                return "TransactionList.rpt";
            }
            set {
                // Do nothing
            }
        }
       
        public override bool NewGenerator {
            get {
                return true;
            }
            set {
                // Do nothing
            }
        }
       
        public override string FullResourceName {
            get {
                return "ABCD.TransactionList.rpt";
            }
            set {
                // Do nothing
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.CrystalReports.Engine.Section Section1 {
            get {
                return this.ReportDefinition.Sections[0];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.CrystalReports.Engine.Section Section2 {
            get {
                return this.ReportDefinition.Sections[1];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.CrystalReports.Engine.Section GroupHeaderSection1 {
            get {
                return this.ReportDefinition.Sections[2];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.CrystalReports.Engine.Section Section3 {
            get {
                return this.ReportDefinition.Sections[3];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.CrystalReports.Engine.Section GroupFooterSection1 {
            get {
                return this.ReportDefinition.Sections[4];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.CrystalReports.Engine.Section Section4 {
            get {
                return this.ReportDefinition.Sections[5];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.CrystalReports.Engine.Section Section5 {
            get {
                return this.ReportDefinition.Sections[6];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.Shared.IParameterField Parameter_AccountName {
            get {
                return this.DataDefinition.ParameterFields[0];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.Shared.IParameterField Parameter_Where {
            get {
                return this.DataDefinition.ParameterFields[1];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.Shared.IParameterField Parameter_Title {
            get {
                return this.DataDefinition.ParameterFields[2];
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public CrystalDecisions.Shared.IParameterField Parameter_PageFooter {
            get {
                return this.DataDefinition.ParameterFields[3];
            }
        }
    }
   
    [System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.ExportOptions), "report.bmp")]
    public class CachedTransactionList : Component, ICachedReport {
       
        public CachedTransactionList() {
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public virtual bool IsCacheable {
            get {
                return true;
            }
            set {
                //
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public virtual bool ShareDBLogonInfo {
            get {
                return false;
            }
            set {
                //
            }
        }
       
        [Browsable(false)]
        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
        public virtual System.TimeSpan CacheTimeOut {
            get {
                return CachedReportConstants.DEFAULT_TIMEOUT;
            }
            set {
                //
            }
        }
       
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() {
            TransactionList rpt = new TransactionList();
            rpt.Site = this.Site;
            return rpt;
        }
       
        public virtual string GetCustomizedCacheKey(RequestContext request) {
            String key = null;
            // // The following is the code used to generate the default
            // // cache key for caching report jobs in the ASP.NET Cache.
            // // Feel free to modify this code to suit your needs.
            // // Returning key == null causes the default cache key to
            // // be generated.
            //
            // key = RequestContext.BuildCompleteCacheKey(
            //     request,
            //     null,       // sReportFilename
            //     this.GetType(),
            //     this.ShareDBLogonInfo );
            return key;
        }
    }
}


Avatar of VITIX

ASKER

After stopping at a break point, and mousing over the object to read the properties, I concluded that the code is not actually creating a report because it cannot find the rpt file. The list of properties on mouseover said something like "file not found" or path not found, etc....

So I changed the path in the report's cs class file code and hard coded it to the C: drive path to the rpt file on my local hard drive. When I run it now I get this error:

"A first chance exception of type 'CrystalDecisions.CrystalReports.Engine.LoadSaveReportException' occurred in CrystalDecisions.CrystalReports.Engine.dll

Additional information: Unable to find the report in the manifest resources. Please build the project, and try again."


Isn't this implying that the project does not know where the rpt file is?? This is an rpt file that I created from scratch in the VS Crystal Designer in the IDE.
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of VITIX

ASKER

Thanks, that's an interesting read. The behaviour I am getting is similar, except that my code will never continue. I get 2 or 3 messages saying "Windows cannot continue from this exception".

I will try changing the debug settings on Monday when I can get back to the office. This may explain why my code runs fine on the other programmer's machine, because his "Exceptions" settings are different than mine. Also why it runs ok in VS 2005, because I had default "Exceptions" settings in VS 2005. (but I have uninstalled 2005 now)

Good lead, I will definitely check into this. Thanks!
Avatar of VITIX

ASKER

I tried changing the debug settings as suggested in the article, but I still get this error. Doesn't matter if I'm in debug mode or if I compile and run the executable, same error pops up.


CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Unable to find the report in the manifest resources. Please build the project, and try again.


The rpt file is located exactly where the code says it should be, but I have no idea how to "fix" this manifest, which only has about 10 or 12 lines of xml in it. Sorry, I'm new at this stuff.
Avatar of VITIX

ASKER

Here is the exception in its entirety:


CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Unable to find the report in the manifest resources. Please build the project, and try again.
   at CrystalDecisions.CrystalReports.Engine.EngineExceptionUtils.DoThrowException(String message, EngineExceptionErrorID id)
   at CrystalDecisions.CrystalReports.Engine.ExceptionThrower.ThrowEngineException(String messageID, EngineExceptionErrorID id)
   at CrystalDecisions.CrystalReports.Engine.ReportClass.Load(String reportName, OpenReportMethod openMethod, Int16 parentJob)
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.EnsureLoadReport()
   at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_DataDefinition()
   at UHHM.frmCashReportsXML.btnTransactionList_Click(Object sender, EventArgs e) in C:\Housing\Housing\UHHM\UHHM\frmCashReportsXML.cs:line 771
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
UHHM
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Housing/Housing/UHHM/UHHM/bin/Debug/UHHM.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 8.0.0.0
    Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Data.DataSetExtensions
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.1 built by: SP
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Data.DataSetExtensions/3.5.0.0__b77a5c561934e089/System.Data.DataSetExtensions.dll
----------------------------------------
System.Core
    Assembly Version: 3.5.0.0
    Win32 Version: 3.5.30729.1 built by: SP
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Transactions
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
CrystalDecisions.Windows.Forms
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.Windows.Forms/10.5.3700.0__692fbea5521e1304/CrystalDecisions.Windows.Forms.dll
----------------------------------------
CrystalDecisions.Shared
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.Shared/10.5.3700.0__692fbea5521e1304/CrystalDecisions.Shared.dll
----------------------------------------
CrystalDecisions.ReportSource
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.ReportSource/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportSource.dll
----------------------------------------
System.Web
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
CrystalDecisions.CrystalReports.Engine
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.CrystalReports.Engine/10.5.3700.0__692fbea5521e1304/CrystalDecisions.CrystalReports.Engine.dll
----------------------------------------
CrystalDecisions.ReportAppServer.CommLayer
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.CommLayer/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.CommLayer.dll
----------------------------------------
CrystalDecisions.ReportAppServer.ClientDoc
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.ClientDoc/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.ClientDoc.dll
----------------------------------------
CrystalDecisions.ReportAppServer.DataSetConversion
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.DataSetConversion/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.DataSetConversion.dll
----------------------------------------
CrystalDecisions.ReportAppServer.DataDefModel
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.DataDefModel/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.DataDefModel.dll
----------------------------------------
CrystalDecisions.ReportAppServer.Controllers
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.Controllers/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.Controllers.dll
----------------------------------------
CrystalDecisions.ReportAppServer.ReportDefModel
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.ReportDefModel/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.ReportDefModel.dll
----------------------------------------
CrystalDecisions.KeyCode
    Assembly Version: 10.5.3700.0
    Win32 Version: 10.5.0.1943
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.KeyCode/10.5.3700.0__692fbea5521e1304/CrystalDecisions.KeyCode.dll
----------------------------------------
Are you running this on the development machine or have you deployed it?

mlmcc
Avatar of VITIX

ASKER

Running on my own machine, entirely in development at this point. The only thing that is not on my machine is the SQL (test) database.
I don't know enough C# to really help

mlmcc
Avatar of VITIX

ASKER

It's been suggested that the way the cs wrapper class is created by VS 2008 is quite different than the wrapper class created by VS2003 or 2005. Tech support was able to demonstrate that the Crystal dll's are workign correctly, and the references in my project are correct. They believe this error/s is caused by the way I am instantiating the report by invoking the wrapper class constructor. The cs wrapper classes I ahve were generated in VS 2005 (possibly in VS 2003) and all I did was run the code thru a VB-to-C# converter and add them to my VS 2008 project. That might explain why the manifest does not recognize the file.  

I noticed that one of my reports started working correctly after I accidentally deleted it and had to recreate it from scratch, thereby causing VS 2008 to generate a new wrapper class.

I'm wondering if there is a way to manually remove the existing wrapper class for the report and force VS to generate a new one, without having to recreate all of the reports from scratch?
Avatar of VITIX

ASKER

Thanks for your time, you helped point me to an overall solution.
I noticed that after I edit the code of the .cs file and remove the following lines, it works. The problem is, the lines keep coming back on subsequent edits and I have to keep removing the lines over and over again every time I make changes to the report:

        public override bool NewGenerator {
            get {
                return true;
            }
            set {
                // Do nothing
            }
        }
       
        public override string FullResourceName {
            get {
                return "NuclearCardiologyReports.Crystal Reports.ThalliumRestOnly24HourFinalReport.rpt";
            }
            set {
                // Do nothing
            }
        }
       
Crystal Reports needs a fix. I have so many reports that it would be costly to redo them.