SamfromDHS
Programmer
When the .NET Framework 2.0 is installed on a machine the crystal viewer will open and run ONE time only within a VFP application. All subsequent attempts to run the viewer results in an OLE Object corrupt error. What’s weird is that simply un-installing .NET 2.0 fixes the problem
here is a small chuch of code to demonstrate the problem.
***
LOCAL oRS as ADODB.Recordset
LOCAL crxDatabaseTable as CRAXDRT.DatabaseTable
LOCAL crxApplication as CRAXDRT.Application
crxApplication=createobject("CrystalRuntime.Application.9")
crxReport=crxApplication.OpenReport([Blank.rpt],1)
oRS=CREATEOBJECT([adodb.recordset])
oRS.CursorType= 3 && adOpenStatic
oRS.CursorLocation= 3 && adUseClient
oRS.Fields.Append([Test1],200,20)
oRS.Open()
oRS.AddNew()
oRS.Fields(0).Value=[Test1]
oRS.AddNew()
oRS.Fields(0).Value=[Test2]
crxDatabase=crxReport.Database
crxDatabaseTables=crxDatabase.Tables
crxDatabaseTable = crxDatabaseTables.Item(1)
crxDatabaseTable.SetDataSource(oRS,3)
oTest=CREATEOBJECT([oCRviewer])
oTest.AddObject("CRViewer1","olecontrol","CRViewer9.CRViewer.9.2")
oTest.WindowState= 2
oTest.CRViewer1.width=oTest.width
oTest.CRViewer1.height=oTest.height
oTest.CRViewer1.Visible=.t.
* Attach the report to the viewer
oTest.CRViewer1.ReportSource=crxReport
oTest.CRViewer1.Refresh()
* View the report
oTest.CRViewer1.ViewReport()
oTest.Show()
DEFINE CLASS oCRviewer as Form
WindowType= 1
ENDDEFINE
*** end code sample
with CR9 runtime installed and VFP9 and .NET 2.0 Framework installed create a blank report with field definition datasource and one string field named test1 length 20. save it where the code above is ran from named "Blank.rpt". Running the code above in the command wirnow will result in a small crystal preview of the blank report. Running it a second time will result in an OLE Object corrupt error, until you exit VFP and re-start, then you can run the preview once more, but only once.
Has anyone else seen this behaviour? could someone else at least validate that what I have isolated is really a VFP or CR9 or .NET 2.0 bug? Thanks and any ideas on what to do is appreciated, I have an application with over 500 crystal reports that won't run with .NET 2.0 installed and some of our users are finding that to be a problem.
here is a small chuch of code to demonstrate the problem.
***
LOCAL oRS as ADODB.Recordset
LOCAL crxDatabaseTable as CRAXDRT.DatabaseTable
LOCAL crxApplication as CRAXDRT.Application
crxApplication=createobject("CrystalRuntime.Application.9")
crxReport=crxApplication.OpenReport([Blank.rpt],1)
oRS=CREATEOBJECT([adodb.recordset])
oRS.CursorType= 3 && adOpenStatic
oRS.CursorLocation= 3 && adUseClient
oRS.Fields.Append([Test1],200,20)
oRS.Open()
oRS.AddNew()
oRS.Fields(0).Value=[Test1]
oRS.AddNew()
oRS.Fields(0).Value=[Test2]
crxDatabase=crxReport.Database
crxDatabaseTables=crxDatabase.Tables
crxDatabaseTable = crxDatabaseTables.Item(1)
crxDatabaseTable.SetDataSource(oRS,3)
oTest=CREATEOBJECT([oCRviewer])
oTest.AddObject("CRViewer1","olecontrol","CRViewer9.CRViewer.9.2")
oTest.WindowState= 2
oTest.CRViewer1.width=oTest.width
oTest.CRViewer1.height=oTest.height
oTest.CRViewer1.Visible=.t.
* Attach the report to the viewer
oTest.CRViewer1.ReportSource=crxReport
oTest.CRViewer1.Refresh()
* View the report
oTest.CRViewer1.ViewReport()
oTest.Show()
DEFINE CLASS oCRviewer as Form
WindowType= 1
ENDDEFINE
*** end code sample
with CR9 runtime installed and VFP9 and .NET 2.0 Framework installed create a blank report with field definition datasource and one string field named test1 length 20. save it where the code above is ran from named "Blank.rpt". Running the code above in the command wirnow will result in a small crystal preview of the blank report. Running it a second time will result in an OLE Object corrupt error, until you exit VFP and re-start, then you can run the preview once more, but only once.
Has anyone else seen this behaviour? could someone else at least validate that what I have isolated is really a VFP or CR9 or .NET 2.0 bug? Thanks and any ideas on what to do is appreciated, I have an application with over 500 crystal reports that won't run with .NET 2.0 installed and some of our users are finding that to be a problem.