Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 9 & CR9 & .NET 2.0 problem

Status
Not open for further replies.

SamfromDHS

Programmer
Mar 17, 2006
3
US
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.
 
I haven't seen this, but I'm using CR 10. Have you posted this on the Crystal forums here on tek-tips?

Craig Berntson
MCSD, Visual FoxPro MVP, Author, CrysDev: A Developer's Guide to Integrating Crystal Reports"
 
No I haven't because I wasn't sure it's a CR9 problem since only installing .NET 2.0 causes the symptom. Thanks for your attention I've read your books
 
Instantiate the object a second time, every thing gets release when the preview closes. By the way as Craig Berntson alluded to, CR10 does not have the problem, so I guess it's only a CR9 issue. I'll now have to test all my reports with the CR10 viewer & .NET 2.0 to ensure they work right.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top