cancel
Showing results for 
Search instead for 
Did you mean: 

Value cannot be null. Parameter name: window

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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)

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

former_member183750
Active Contributor
0 Kudos

I believe the issue is noted in the KB [1544651 - Crystal Reports WPF Viewer fails with NullReferenceException when used in a WinForms application|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333533343334333633353331%7D.do].

The cool thing here is that you made it work and I'm looking forward to trying it my self. The not so cool thing is that anyone doing this needs to understand that this is not a supported scenario as per the above KB. E.g.; if other issue crop up while using this approach, we'll try to help, but there is no escalation path to R&D for any fixes.

- Ludek

Former Member
0 Kudos

Hi Ludek,

So far it seems solid.

However my app is WPF and I'm using the WPF control... I wasn't able to replicate the issue in a bare-bones test so I suspect that some interplay between my devcomponents ribbon window and crystal is causing the problem - either that or I suck at WPF programming. And funnily enough, clients running Win XP didn't have the same probelm as Win7 clients... I have not tried any Win7 32 bit clients, so maybe there's another thought.

All that's left is for to try and figure out why I don't get a database login screen, but clients do..

Michael

former_member183750
Active Contributor
0 Kudos

Hi Michael

why I don't get a database login screen, but clients do..

Many possible reasons. I wrote an article on the most usual suspects:

[Troubleshooting Guide to Database Connectivity Issues with Crystal Reports in Visual Studio .NET Applications|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b0225775-88c4-2c10-bd80-8298769293de] and that may be worth looking at.

The 1st thing I'd go after in this case is ensuring that the correct database client is installed on that box. You can check that by using the [Modules|https://smpdl.sap-ag.de/~sapidp/012002523100006252802008E/modules.zip] utility and comparing what is actually loaded by the app. It will not be anything to do with CR dlls as there is no Service Packs yet to confuse the issue.

And I'm outta here :).

Have a great evening,

Ludek

Former Member
0 Kudos

I'm having the same issue. Value cannot be null. Parameter name: window

I'm running on Windows 7 64 bits, VS 2010, WPF application, C#, CRVS2010 version 13.0.2000.0

Using the SAPBusinessObjects.WPF.Viewer. I'm stuck with the development of my application

Any solution on this from SAP people?

I appreciate your help..

Former Member
0 Kudos

Using Visual Studio 2010, WPF .Net 4.0 full, Crystal Reports 13.0.200.0

Also having this problem when opening the WPF viewer in a (sub) window.

 
public void LoadReport(object document, Report report)
        {
            var reportDocument = document as ReportDocument;

            if (reportDocument != null)
            {
                if (((ReportDocument)ReportViewer.ViewerCore.ReportSource).Equals(reportDocument))
                    AppendParametersToViewer(reportDocument.ParameterFields);
                else
                {
                    ReportViewer.ViewerCore.ReportSource = reportDocument;
                }
            }
        }
        
        private void AppendParametersToViewer(ParameterFields parameterFields)
        {
            // This disables the prompt for manualy entering parameters
            ReportViewer.ViewerCore.ReuseParameterWhenRefresh = true;
            ReportViewer.ViewerCore.ParameterFieldInfo = parameterFields;
            ReportViewer.ViewerCore.RefreshReport();
            ReportViewer.ViewerCore.ReuseParameterWhenRefresh = false;
        }

former_member183750
Active Contributor
0 Kudos

Do you get the same issue following the steps as described in [this|http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/a09f7025-0629-2d10-d7ae-df006a51d1a8] demo?

Ludek

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi all,

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

Thanks.

Martin

Former Member
0 Kudos

Hi all,

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

Thanks.

Martin

0 Kudos

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

Former Member
0 Kudos

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

former_member183750
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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 ....

Former Member
0 Kudos

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!!

Former Member
0 Kudos

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