16 Replies Latest reply: Aug 26, 2011 5:12 PM by Ludek Uher RSS

Value cannot be null. Parameter name: window

Michael Ireland
Currently Being Moderated

Hi,

 

I have an issue where when loading a report within a WPF Page, Crystal throws the following exception:

 

-


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)

       at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.GetDesktopDpi()

       at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.GetSingleLinePenThicknessX()

       at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.SnapPenThickness(Pen& pen)

       at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.DrawRectangleSnapped(DrawingContext context, Brush brush, Pen pen, Rect rect)

       at SAPBusinessObjects.WPF.ViewerShared.PageView.drawPageBackground(Int32 reservedMargin)

       at SAPBusinessObjects.WPF.ViewerShared.PageView.Render()

       at SAPBusinessObjects.WPF.ViewerShared.PageView.set_PageObj(PageObject value)

       at SAPBusinessObjects.WPF.Viewer.DocumentView.ShowNthPage(Int32 PageNumber, Boolean hasAnimation)

       at SAPBusinessObjects.WPF.Viewer.ReportAlbum.OnCreateNewDocumentViewComplete(CreateNewDocumentArgs args)

       at SAPBusinessObjects.WPF.Viewer.DelegateMarshaler.<>c__DisplayClass6`1.<Invoke>b__4(Object )

       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

       at System.Windows.Threading.DispatcherOperation.InvokeImpl()

       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)

       at System.Threading.ExecutionContext.runTryCode(Object userData)

       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)

       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Windows.Threading.DispatcherOperation.Invoke()

       at System.Windows.Threading.Dispatcher.ProcessQueue()

       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)

       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)

       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)

       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)

       at System.Windows.Threading.Dispatcher.Run()

       at System.Windows.Application.RunDispatcher(Object ignore)

       at System.Windows.Application.RunInternal(Window window)

       at System.Windows.Application.Run(Window window)

       at System.Windows.Application.Run()

       at Beast3Client.Application.Main() in C:\Software Development\Beast 3\Beast 3\Beast 3 Client\obj\x86\Debug\Application.g.vb:line 79

       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)

       at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)

       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)

       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()

       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)

       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)

       at System.Activator.CreateInstance(ActivationContext activationContext)

       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()

       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ThreadHelper.ThreadStart()

  InnerException:

-


 

This happens on the line of code:

        Dim Rpt As BDMAllocation

        Rpt = New BDMAllocation

        Rpt.Load()

        Try

            CrystalReportsViewer1.ViewerCore.ReportSource = Rpt  ' <------ Error occurs here

        Catch ex As Exception

 

        End Try

 

The Try block does not capture this exception.

 

I have confirmed that I am using the RTM version of the crystal SDK, and all relevant files are stamped version 13. This exception occurs for both embedded reports and externally loaded reports.

 

 

However, when I attempt to open a new Window and present the same report in this new Window, it shows fine.

 

My environment is as below:

VS 2010  - using VB with .NET 4 full

OS is Win7 64 bit

  • Re: Value cannot be null. Parameter name: window
    Michael Ireland
    Currently Being Moderated

    Wow... the formatting above is terrible.. Sorry about that. Let me try and reformat it to look readable

  • Re: Value cannot be null. Parameter name: window
    Michael Ireland
    Currently Being Moderated

    Exception Details

     

    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)
           at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.GetDesktopDpi()
           at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.GetSingleLinePenThicknessX()
           at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.SnapPenThickness(Pen& pen)
           at SAPBusinessObjects.WPF.ViewerShared.WPFUtils.DrawRectangleSnapped(DrawingContext context, Brush brush, Pen pen, Rect rect)
           at SAPBusinessObjects.WPF.ViewerShared.PageView.drawPageBackground(Int32 reservedMargin)
           at SAPBusinessObjects.WPF.ViewerShared.PageView.Render()
           at SAPBusinessObjects.WPF.ViewerShared.PageView.set_PageObj(PageObject value)
           at SAPBusinessObjects.WPF.Viewer.DocumentView.ShowNthPage(Int32 PageNumber, Boolean hasAnimation)
           at SAPBusinessObjects.WPF.Viewer.ReportAlbum.OnCreateNewDocumentViewComplete(CreateNewDocumentArgs args)
           at SAPBusinessObjects.WPF.Viewer.DelegateMarshaler.<>c__DisplayClass6`1.<Invoke>b__4(Object )
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.DispatcherOperation.InvokeImpl()
           at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Windows.Threading.DispatcherOperation.Invoke()
           at System.Windows.Threading.Dispatcher.ProcessQueue()
           at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
           at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
           at System.Windows.Threading.Dispatcher.Run()
           at System.Windows.Application.RunDispatcher(Object ignore)
           at System.Windows.Application.RunInternal(Window window)
           at System.Windows.Application.Run(Window window)
           at System.Windows.Application.Run()
           at Beast3Client.Application.Main() in C:\Software Development\Beast 3\Beast 3\Beast 3 Client\obj\x86\Debug\Application.g.vb:line 79
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
           at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[]  activationCustomData)
           at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
           at System.Activator.CreateInstance(ActivationContext activationContext)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

     

    • Re: Value cannot be null. Parameter name: window
      Michael Ireland
      Currently Being Moderated

      This happens on the line of code:

       

      Dim Rpt As BDMAllocation 
      Rpt = New BDMAllocation 
      Rpt.Load() 
      Try 
        CrystalReportsViewer1.ViewerCore.ReportSource = Rpt ' <------ Error occurs here 
      Catch ex As Exception 
      End Try

       

       

      Environment Details

      Visual Studio 2010, VB

      Win 7 64 bit

       

      The Try block does not capture this exception. I have confirmed that I am using the RTM version of the crystal SDK, and all relevant files are stamped version 13. This exception occurs for both embedded reports and externally loaded reports.

       

      However, when I attempt to open a new Window and present the same report in this new Window, it shows fine.

      • Re: Value cannot be null. Parameter name: window
        Michael Ireland
        Currently Being Moderated

        I have found a workaround - although it is a little messy:

         

        Step 1) Create the viewer in code, not XAML

        Step 2) Create a hidden window, insert the viewer in the window as well as the frame where I will present to the user

        Step 3) Handle the destruction of the hidden window

         

                Dim Rpt As CrystalDecisions.CrystalReports.Engine.ReportClass
                Rpt = GetReport()
                Rpt.DataSourceConnections(0).SetConnection("xxxx", "xxxxxxxx", True)
                Rpt.Load()
        
                If Not W Is Nothing Then
                    W.Close()
                    W = Nothing
                End If
                Try
                    Dim CRV As SAPBusinessObjects.WPF.Viewer.CrystalReportsViewer
                    CRV = New SAPBusinessObjects.WPF.Viewer.CrystalReportsViewer
                    CRV.Margin = New System.Windows.Thickness(0, 0, 0, 0)
                    CRV.HorizontalAlignment = Windows.HorizontalAlignment.Stretch
                    CRV.VerticalAlignment = Windows.VerticalAlignment.Stretch
                    AddHandler CRV.Unloaded, AddressOf CrystalReportsViewer1_Unloaded
                    Frame1.NavigationUIVisibility = NavigationUIVisibility.Hidden
                    Frame1.Content = CRV
        
                    W = New DevComponents.WpfRibbon.AdvWindow
                    With W
                        .WindowStartupLocation = WindowStartupLocation.CenterScreen
                        .Title = Me.Title
                        .Height = 600
                        .Width = 800
                        .Content = CRV
                        .WindowState = WindowState.Normal
                        .ShowInTaskbar = True
                    End With
        
                    CRV.ViewerCore.ReportSource = Rpt
        
                Catch ex As Exception
        
                End Try

         

        And the window destruction:

         

            Private Sub CrystalReportsViewer1_Unloaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) 
                If Not W Is Nothing Then
                    W.Close()
                    W = Nothing
                End If
            End Sub

         

  • Re: Value cannot be null. Parameter name: window
    Sergiu Borg
    Currently Being Moderated

    hello,

     

    I have the exact same issue here, I have a WPF appication also I'm using a win XP with VS 2010 and CR v 13 ... the funny thing is if I install beta 2 of CR v 14 everything works fine, so what is the deal here ? anybody found a good workaround because the whole DevComponents.WpfRibbon.AdvWindow example shown above is a little beyond my understanding ....

    • Re: Value cannot be null. Parameter name: window
      Frank Kotulak
      Currently Being Moderated

      Having the same problems here using VB in VS 2010 and the RTM for Crystal and WPF. I am on a Win 7 box, the 6 line application is under the 4.0 framework as an x86 application.

       

      I purt a viewer on a standard WPF form with no underlying containers and used the following code tied to a button click.

       

              Dim crpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument

       

              crpt.Load("C:\Hold Area\RMS Workload Reports\Employee WorkSteps by Workstep.rpt")

       

              CrystalReportsViewer1.ViewerCore.ReportSource = crpt

       

      I use the following imports

       

      Imports CrystalDecisions.CrystalReports.Engine

      Imports CrystalDecisions.Shared

      Imports SAPBusinessObjects.WPF.Viewer

       

      I have tried binding to reports with and without parameters and in all cases I get the Value cannot be null. Parameter name: window error as a "no source" error in VS2010.

       

      As previously stated if I replace all of teh above code with

       

      CrystalReportsViewer1.ShowOpenFileButton = True

       

      Then run the app the viewer correctly displays. If I then open those same reports within the viewer they open correctly. If parameters required they show. If no parameters the report shows immediatley.

       

      I am stuck and cannot proceed!!

  • Re: Value cannot be null. Parameter name: window
    Raedon Finecode
    Currently Being Moderated

    This issue isn't fixed even in the final version. I suppose it's handeled exception in a wrong way when the crystal engine is trying to cast parameters that you pass to your report. Seem like the parameter window is not set, but somewhere in the code there are trying to iterate with it. You can patch your reports using a string parmaeters.

  • Re: Value cannot be null. Parameter name: window
    Pieter Jong
    Currently Being Moderated

    Hi All,

     

    To respond to this thread.

     

    It doesn't seem like there has been made a solution for this problem.

     

    The error ocurred when the Crystal Reports Viewer (WPF) wants to show an error message box. This error message box is based on the default windows MessageBox.

     

    This is a problem that needs to be fixed in the Crystal Reports components.

     

    To try and replicate this problem, the following procedure can be followed:

     

    - Create a new Crystal Reports report.

    - Include some tables/views in the report

    - Open the report using a custom build WPF Crystal Reports Viewer

    - This should work

    - Remove a table/view that is used in the report from the database

    - Open the report again using a custom build WPF Crystal Reports Viewer

    - Now the error "Value cannot be null. Parameter name: window" will be thrown

     

    Hope a solution can be found for this problem.

     

    Kind regards,

    Pieter Jong

     

    Crystal Advice

    http://www.crystaladvice.com

    • Re: Value cannot be null. Parameter name: window
      Tyler P
      Currently Being Moderated

      Hello,

       

      I'm also having this issue with Crystal for VS 2010 (WPF viewer). When exporting a report with 20,000+ pages to Excel 97-2003 Data Only, I get this message:

      System.ArgumentNullException was unhandled
      Message: Value cannot be null.
      Parameter name: window

      The message doesn't occur right away, it probably takes about 10minutes into the exporting process be for it appears.

       

      When running the report in crystal designer with the same parameters and exporting the report the same way, it exports fine without issues. It takes about 15mins to export the report in Crystal 2008 Designer.

       

      Any ideas? When will the next service pack or fix pack be released for Crystal VS 2010?

       

      Thank you,

      TP

      • Re: Value cannot be null. Parameter name: window
        Ludek Uher
        Currently Being Moderated

        Hello Tyler

         

         

        I'm pretty sure we're looking at two different issues here(?). Same error, but it looks tome like it is caused by a different set of steps...

         

        Can you please create a new thread on this? Also in that thread, let me know if you can share the report so I can test with it here.

         

        Re. Next service pack for CR. Probably not until next year... but even if it makes it before your issue would, more than likely, not be addressed in the sp.

         

        Oh, and also see the blog [What are these "support" forums good for anyhow?|http://weblogs.sdn.sap.com/pub/wlg/24164]

         

         

         

        - Ludek

  • Re: Value cannot be null. Parameter name: window
    Martin Kurek
    Currently Being Moderated

    Hi all,

    I find reason and [solution on WPF Crystal Reports exception: Value cannot be null. Parameter name: window.|WPF exception: Value cannot be null. Parameter name: window - SOLUTION;

    Thanks.

    Martin

  • Re: Value cannot be null. Parameter name: window
    Martin Kurek
    Currently Being Moderated

    Hi all,

    I find reason and [solution on WPF Crystal Reports exception: Value cannot be null. Parameter name: window.|WPF exception: Value cannot be null. Parameter name: window - SOLUTION;

    Thanks.

    Martin

Actions