Code Snippets

Guy posted on July 02, 2007 :: 11422 views

This code contains a Crystal Report viewer wrapper control which can be used to integrate Crystal Reports into Visual WebGui. The control inherits from AspControlBoxBase class that enables wrapping ASP.NET controls into Visual WebGui controls.

In order to use this code in your library you should copy the class into a project and add references to CrystalDecisions.Shared and CrystalDecisions.Web which are used by the control. The control does support design time placing but you should assign the report at run-time.

Versions:

  • 1.0: First release of the wrapper control.
  • 1.1:
    • Converted to VB.NET.
    • Added containing project.
    • Fixed "invalid  report path error".
    • Fixed the missing images (added asp_client directory).
  • 1.2:
    • Added default value for the ToolbarStyle property.
    • Added default value for the GroupTreeStyle property.
    • Added default value for the PrintMode property.

Note: Codes are submitted as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Terms of Agreement:
By using this code, you agree to the following terms...

  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame.
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

# vina_m1
i am using VWG version 3 and this wrapper control is using version 2 i believe. when i tried to use it in my project (in VS 2008 VWG) it gave me an error about a conflect of versions i believe...

any ideas how to use this control? i am using VWG in Visual Studio 2008..

Thanks
Posted by vina_m1 on Monday, March 31, 2008 2:14 PM
# rdhatch
I'm getting an error trying to incorporate this into my project. This demo runs fine - until you remove the CrystalReportViewer from the Form and try to readd it by dragging it from the Toolbox. Errors ensue. Please help! An email would be greatly appreciated.

Error Screenshots:
-------------------------
http://www.konect.com/temp/ClientTarget.RunTime Error.jpg
http://www.konect.com/temp/DesignTime.ToolbarStyle.NullError.jpg

Software Versions:
-------------------------
Visual Web GUI v5.83.3 (.NET 2.0)
Visual Studio 2005
Crystal Reports v10.2.3600.0

Ryan D. Hatch
ryan.hatch | konect dot com
Posted by rdhatch on Monday, March 31, 2008 10:50 PM
# rdhatch
Ok, I found the fix. The code that is generated when Dragging & Dropping the CrystalReportViewer onto a Form/User Control is incorrect. Here is the fix. Replace generated code with the code below. Enjoy!

Ryan D. Hatch
--
[Put in Form/User Control ____.Designer.vb, anywhere a CrystalReportViewer is used]


Private Sub InitializeComponent()
Me.CrystalReportViewer1 = New VWGCrystal.CrystalReportViewer
Me.SuspendLayout()
'
'CrystalReportViewer1
'
Me.CrystalReportViewer1.BackgroundImageLayout = Gizmox.WebGUI.Forms.ImageLayout.Tile
Me.CrystalReportViewer1.ClientSize = New System.Drawing.Size(811, 811)
Me.CrystalReportViewer1.ClientTarget = "Auto"
Me.CrystalReportViewer1.Cursor = Gizmox.WebGUI.Forms.Cursors.Default
Me.CrystalReportViewer1.Dock = Gizmox.WebGUI.Forms.DockStyle.Fill
Me.CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
Me.CrystalReportViewer1.Margin = New Gizmox.WebGUI.Forms.Padding(0)
Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
Me.CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.Pdf
Me.CrystalReportViewer1.Size = New System.Drawing.Size(811, 811)
Me.CrystalReportViewer1.TabIndex = 0
Me.CrystalReportViewer1.Text = "CrystalReportViewer1"

[...........]
[End Sub]


Friend WithEvents CrystalReportViewer1 As VWGCrystal.CrystalReportViewer
Posted by rdhatch on Tuesday, April 01, 2008 1:00 AM
# rdhatch
Well, apparently - that code fixed the demo project contained here. I was able to remove the control from the Form and readd it, and overwrite the code generated within Designer.vb just fine. That seemed to fix the demo project.

However - when I attempted this in my own project - Visual Studio keeps overwriting my changes inside Designer.vb. I keep getting the "ToolbarStyle" "null is not allowed" error. Here is the code VS is generating, which seems to be causing the error:

--

'
'CrystalReportViewer1
'
Me.CrystalReportViewer1.Anchor = Gizmox.WebGUI.Forms.AnchorStyles.None
Me.CrystalReportViewer1.ClientTarget = "Auto"
Me.CrystalReportViewer1.Dock = Gizmox.WebGUI.Forms.DockStyle.Fill
Me.CrystalReportViewer1.DrilldownTarget = "True"
Me.CrystalReportViewer1.GroupTreeImagesFolderUrl = ""
Me.CrystalReportViewer1.HasRefreshButton = True
Me.CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
Me.CrystalReportViewer1.PageToTreeRatio = 0
Me.CrystalReportViewer1.PageZoomFactor = 0
Me.CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.Pdf
Me.CrystalReportViewer1.ShowAllPageIds = True
Me.CrystalReportViewer1.Size = New System.Drawing.Size(796, 789)
Me.CrystalReportViewer1.TabIndex = 0
Me.CrystalReportViewer1.Text = "CrystalReportViewer1"
Me.CrystalReportViewer1.ToolbarImagesFolderUrl = ""

How do I fix this? Please help! Email would be greatly appreciated.

Ryan D. Hatch
ryan.hatch | konect dot com
Posted by rdhatch on Tuesday, April 01, 2008 1:19 AM
# vina_m1
Please i need a detailed example on how to use that. do i just add the DLL to my references and call the crystalreportviewer of the VWGCrystal?? or do i add a crystalReportViewer from the toolbox myself?? (when i do that, i dont see anything in the form, as if it did not add anything!!). also do i need to add anything to the web.config?? does it matter if i am using version 3 of VWG?

Please help

Thanks
Posted by vina_m1 on Tuesday, April 01, 2008 9:58 AM
# rdhatch
To use this, you add the CrystalWrapper file to your project, then rebuild. Now go into Design view of your Form or User Control - you will see the CrystalReportViewer in your Toolbox under the name of your project. Drag this onto the Form or User Control.

Problem is - the auto-generated code in the Designer.vb files causes errors.

All I get is errors, continously. "ToolbarStyle null"

Please help!

Ryan D. Hatch
ryan.hatch | konect dot com
Posted by rdhatch on Tuesday, April 01, 2008 10:17 AM
# shlomi.bin
Hi,

I figured out what seems to be the wrapper's problem. In order to stop these annoying messages from the designer, you'll have to add default values to some of its properties:

1. Return GetObjectParam("ToolbarStyle", New ToolbarStyle())
2. Return GetObjectParam("GroupTreeStyle", New GroupTreeStyle())
3. Return GetObjectParam("PrintMode", PrintMode.Pdf)

Hope it helps,

Shlomi
Posted by shlomi.bin on Wednesday, April 02, 2008 4:21 AM
# shlomi.bin
Hi,

I uploaded a new version of the ZIP file as well - for your convenient.

Shlomi
Posted by shlomi.bin on Wednesday, April 02, 2008 4:37 AM
# vina_m1
perfect...i got it to work on my machine finally :) but now i have a small problem!! when i run the application on the deploying machine (which doesn't have crystal installed) i get this error:

"Could not load file or assembly 'CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified."

does anyone have the msi file to add these dlls to the deploying machine? the deploying machine only have these dlls in version 10.2.3600.0

Please help...i need this ASAP

Thanks alot for all the hard work!
Posted by vina_m1 on Thursday, April 03, 2008 9:41 AM
# oti
First of all I would like to excuse me for my English.

I have add as reference, the VWGCrystal.dll. I drag and drop the CrystalReportViewer(the control that was generated from the dll) on the form and when the project is being compiled an exception is shown at the mozila

Value does not fall within the expected range.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Value does not fall within the expected range.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: Value does not fall within the expected range.]
CrystalDecisions.Web.CrystalReportViewerBase.set_ClientTarget(String value) +78
CrystalDecisions.Web.CrystalReportViewer.set_ClientTarget(String value) +33
VWGCrystal.VWGCrystal.CrystalReportViewer.get_InternalReportViewer() +395
VWGCrystal.VWGCrystal.CrystalReportViewer.GetHostedControl(Page objASPPage) +225
Gizmox.WebGUI.Forms.Hosts.AspControlBoxBase.CreateHostPage() +349
Gizmox.WebGUI.Forms.Hosts.AspControlBoxBase.Gizmox.WebGUI.Common.Interfaces.IGatewayControl.GetGatewayHandler(IContext objContext, String strAction) +33
Gizmox.WebGUI.Common.Gateways.Gateway.ProcessRequest(HttpContext objHttpContext) +374

[HttpException (0x80004005): Value does not fall within the expected range.]
Gizmox.WebGUI.Common.Gateways.Gateway.ProcessRequest(HttpContext objHttpContext) +864
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
Posted by oti on Tuesday, May 27, 2008 4:21 AM
# dennisdodson
I'm getting the same error today like oti @ Tuesday, May 27, 2008 4:21 AM above is.

I'm using IE7 and Crystal 11.5.3700.0

Help!!!
Posted by dennisdodson on Thursday, May 29, 2008 5:02 PM
# dennisdodson
Also, the .Zip file does not contain the two tester projects that are referenced in the Solution File - ASPCrystalTester and VWGCrystalTester.

How can I acquire?
Posted by dennisdodson on Thursday, May 29, 2008 5:07 PM
# rdhatch
Ok, I have everything working great on Crystal 10.x

I've created a demo project for you all. Hopefully it works on 11.x as well.

Ryan

Download: http://www.konect.com/temp/2008.05.29.RyansVWGCrystalWrapper.zip


PS. I wish I could upload code to this VWG website instead of my own. Permission denied when I tried adding a Code Snippet.
Posted by rdhatch on Thursday, May 29, 2008 7:26 PM
# rdhatch
Also, To install Crystal Reports on the deployment server using MSI Redistributable - you can find the MSI file in your local Visual Studio folder:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\CrystalReports\CRRedist2005_x86.msi
Posted by rdhatch on Thursday, May 29, 2008 7:33 PM
# dennisdodson
Ryan, thanks for the code, it helped.

Now I get this error:

Unable to cast object of type 'Gizmox.WebGUI.Forms.Component[]' to type 'Gizmox.WebGUI.Forms.Control[]'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'Gizmox.WebGUI.Forms.Component[]' to type 'Gizmox.WebGUI.Forms.Control[]'.

Source Error:

Line 25: 'VwgCrystalViewer1
Line 26: '
Line 27: Me.VwgCrystalViewer1.DragTargets = New Gizmox.WebGUI.Forms.Component(-1) {}
Line 28: Me.VwgCrystalViewer1.Location = New System.Drawing.Point(155, 84)
Line 29: Me.VwgCrystalViewer1.Name = "VwgCrystalViewer1"


Source File: C:\Program Files\Gizmox\RyansCrystalWrapper\Form1.Designer.vb Line: 27

Stack Trace:


[InvalidCastException: Unable to cast object of type 'Gizmox.WebGUI.Forms.Component[]' to type 'Gizmox.WebGUI.Forms.Control[]'.]
RyansCrystalWrapper.Form1.InitializeComponent() in C:\Program Files\Gizmox\RyansCrystalWrapper\Form1.Designer.vb:27
RyansCrystalWrapper.Form1..ctor() +193

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +103
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +268
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1036
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +114
Gizmox.WebGUI.Server.Context.50AA0(String 0AAAA, String 1AAAA, Object[] 2AAAA) +48
Gizmox.WebGUI.Server.Context.CreateMainForm() +187
Gizmox.WebGUI.Server.Content.GetMainForm() +366
Gizmox.WebGUI.Server.Content.ProcessRequest(HttpContext objHttpContext) +704

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
Gizmox.WebGUI.Server.Content.ProcessRequest(HttpContext objHttpContext) +4375
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; WebGui Version:2.0.50727.1433
Posted by dennisdodson on Friday, May 30, 2008 11:17 AM
# rdhatch
Hi Dennis,

What build of VWG are you using?

I'm using v6.0.2 and that code works fine for me.

Ryan
Posted by rdhatch on Friday, May 30, 2008 12:06 PM
# dennisdodson
Ryan,

I'm using .Net 2.0 build 5.84.2

Will do upgrade and advise.

Thanks...
Posted by dennisdodson on Friday, May 30, 2008 12:13 PM
# dennisdodson
Ryan,

I upgraded to v6.0.2 and form rendered!

I did however, had to add the following to
VWGCrystalViewer.Designer.vb:

Dim myToolbarStyle As CrystalDecisions.Shared.ToolbarStyle = New CrystalDecisions.Shared.ToolbarStyle
Me.CrystalReportViewer.ToolbarStyle = myToolbarStyle

The only other thing to do is find the images to
add to the ToolbarImagesFolderUrl property.

Thanks again for the help.
Posted by dennisdodson on Friday, May 30, 2008 12:50 PM
# rdhatch
Glad you got it to work!!

To get the Crystal Toolbar Images - simply copy the aspnet_client folder from my project into the root folder of your VWG project.

Should be good to go.

Ryan
Posted by rdhatch on Friday, May 30, 2008 12:52 PM
# oti
When I add images to a crystal report, the embedded images are not shown when the application is running.

Is there a specific folder that this images should
be in.
Currently for the images I'm using the default resources/images folder
Posted by oti on Friday, June 27, 2008 2:51 AM
# RTORT
This cystal wrapper, is avaible on VWG version 3 and VS 2008 VWG??
Posted by RTORT on Monday, July 14, 2008 10:36 AM
# nosh99
when i try to open the 'VWGCrystal.vbproj' file i face this problem:


Microsoft Development Environment
---------------------------
Unable to read the project file 'VWGCrystal.vbproj'. The file 'D:\E_Books\VB.net\CrystalReportCode\Gizmox.WebGUI.CrystalReports.CrystalReportViewer.1.2\VWGCrystal.vbproj' is not a valid project file. The project file is missing the 'VisualStudioProject' section.
Posted by nosh99 on Tuesday, July 15, 2008 6:00 AM
# piyusht
Hi,

I'm having problem in printing the report. The pint button points to a dialog which always exports the report in PDF. When I changed my default printer from Adobe PDF to some other it doesn't work. It shows page cannot be displayed error.
Posted by piyusht on Thursday, November 20, 2008 12:35 AM
# rdhatch
Gizmox - can you please post the newer Crystal Reports wrapper here? This is an old version of the Crystal Wrapper. I have a demo here:

http://support.visualwebgui.com/issue/ViewIssue.aspx?ID=3764

However - I do not see how Design-time is NOT supported now - but it was supported previously in older versions of this wrapper.

Ryan
Posted by rdhatch on Friday, February 06, 2009 11:12 AM
# Rochmad Sigit
i'm using this control
so far is good enough

but when i'm working with chart report and i deploy it on server why my chart doesn't appear on report?
is there some of u guys know why

Thanks
warm regards,

Rochmad
Posted by Rochmad Sigit on Sunday, April 05, 2009 11:25 PM
# rdhatch
Hi Rochmad -

This code is now deprecated. Please see new Crystal Reports Viewer here:

http://www.visualwebgui.com/Developers/Resources/Codes/tabid/326/articleType/ArticleView/articleId/481/Crystal-Reports-Viewer.aspx

Ryan
Posted by rdhatch on Monday, April 06, 2009 9:10 AM
# Rochmad Sigit
Hi Ryan,
Thanks very much,
i'll try it

regards,


Rochmad
Posted by Rochmad Sigit on Tuesday, April 07, 2009 11:20 PM
Only registered users may post comments.
Most promising startups
Top 3 most promising startups in 2009
   AJAX Framework | Web Development | RIA Development | Silverlight Applications | Silverlight Controls | RIA Tutorials
The most popular open source Ajax / Silverlight RIA platform for enterprises | Sitemap | Terms Of Use | Privacy Statement
Copyright © 2005-2009 Visual WebGui®    Design By: Template World
   
Visual Studio Partners