SAP Knowledge Base Article - Public

1707202 - How to use the WPF viewer in a WinForm using a Element Host

Symptom

  • Incorrect coding causes the following error:


Value cannot be null. Parameter name: window
 
System.ArgumentNullException was unhandled
  Message=Value cannot be null.
Parameter name: window
  Source=PresentationFramework
  ParamName=window
  StackTrace:

       at System.Windows.Interop.WindowInteropHelper..ctor(Window window)

 

Environment

  • Crystal Reports for Visual Studio 2010
  • Visual Studio 2010

Cause

  • SAPBusinessObjects.WPF.Viewer.ViewerCore.Owner is NULL

Resolution

  1. Create a Windows application
  2. Set the viewer owner to the window
  3. Use the WindowInteropHelper to set the owner
System.Windows.Window window = new System.Windows.Window();   
viewer.Owner = window;  
System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(window);  
Helper.Owner = this.Handle; 

Keywords

CR2010 2010 CR4VS2010 CR4VS VS2010 NET2010 Crystal Reports for .NET Framework 4.0 crforvs 13 , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio