cancel
Showing results for 
Search instead for 
Did you mean: 

NullReferenceException in OnCreateNewDocumentViewComplete

0 Kudos

Hi I am having a problem with the crystal reports viewer, it is crashing with a NullRefrenceException after loading the report file in the OnCreateNewDocumentViewComplete() method (the ReportSource is set via binding).

It appears that the line:

(this.tabViews.ItemContainerGenerator.ContainerFromItem(item)
as TabItem).CommandBindings.Add(new CommandBinding(TabClose, new
ExecutedRoutedEventHandler(this.TabCloseExecuted)))

is the issue, I suspect this.tabViews.ItemContainerGenerator.ContainerFromItem(item) returns null as the viewer is in a tabbed tool window (we use Actipro docking Control for window docking) and it is currently not the active tab.

Does anyone have any idea what I can do to get around this issue, I don't seem to be able to catch the exception anywhere.

Call stack follows:

SAPBusinessObjects.WPF.Viewer.dll!SAPBusinessObjects.WPF.Viewer.ReportAlbum.OnCreateNewDocumentViewComplete(SAPBusinessObjects.WPF.Viewer.ReportAlbum.CreateNewDocumentArgs
args = {SAPBusinessObjects.WPF.Viewer.ReportAlbum.CreateNewDocumentArgs})
SAPBusinessObjects.WPF.Viewer.dll!SAPBusinessObjects.WPF.Viewer.DelegateMarshaler.Invoke.AnonymousMethod__0(object
<state> = null)WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate
callback, object args, int numArgs)WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object
source = {System.Windows.Threading.Dispatcher}, System.Delegate callback,
object args, int numArgs, System.Delegate catchHandler = null)WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl()WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(object
obj)mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext
executionContext, System.Threading.ContextCallback callback, object state, bool
preserveSyncCtx)mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext
executionContext, System.Threading.ContextCallback callback, object state, bool
preserveSyncCtx)mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext
executionContext, System.Threading.ContextCallback callback, object state)WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext
executionContext = {MS.Internal.CulturePreservingExecutionContext},
System.Threading.ContextCallback callback, object state)WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke()WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue()WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr
hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr
hwnd = 0x0000000001160fe6, int msg, System.IntPtr wParam = 0x0000000000000001,
System.IntPtr lParam = 0x0000000000000000, ref bool handled = false)WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object
o)WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate
callback, object args, int numArgs)WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object
source = {System.Windows.Threading.Dispatcher}, System.Delegate callback,
object args, int numArgs, System.Delegate catchHandler = null)WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority
priority, System.TimeSpan timeout, System.Delegate method, object args, int
numArgs)WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr
hwnd = 0x0000000001160fe6, int msg, System.IntPtr wParam = 0x0000000000000001,
System.IntPtr lParam = 0x0000000000000000)[Native to Managed Transition]Annotated Frame[Managed to Native Transition]Annotated Frame WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame
frame = {System.Windows.Threading.DispatcherFrame})PresentationFramework.dll!System.Windows.Application.RunDispatcher(object
ignore)PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window
window)Paragon.Presentation.Applications.MasterDataEditor.exe!Paragon.Presentation.Applications.MasterDataEditor.App.Main()

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos
0 Kudos

We are on SP22, looking at the release notes for versions 23 and 24 there is nothing listed which sounds like it would address this issue and as upgrading CrystalReports is such a pain (Please support nuget!) I'm reluctant to embark on the process without at least some hope of a fix.

I have a workaround; by activating (UpdateLayout doesn't work) the containing window when I set the ReportSource I can avoid the crash, however this obviously forces the report to the top of the display and when you have multiple report windows this looks quite messy I expect users to complain that it is messing up their carefully organised window layout.

Answers (2)

Answers (2)

This was happening to me when put the ReportViewer inside a TabControl.

Moving it to the Layout Root solved my problem

0 Kudos

Not all fixes are listed in the doc.

We don't fix older versions, we only release updates as a full build.

So if a fix is required first thing you need to do is try SP 24 to see if it fixes it. If it does not then I'll get hold of you for a sample app that duplicates the issue for R&D to use to resolve the issue.

I believe the nuget issue is due to a MS problem...

Don