on 11-15-2010 1:30 PM
I have upgraded a project from CR for VS 2008 to 2010. I am developing using VS 2010, .NET 4.0, and WPF. I am adding a strong typed report and trying to view it inside the WPF Viewer as follows:
XAML:
xmlns:cr="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer"
....
<DockPanel Grid.Row="0" LastChildFill="True" Background="AliceBlue">
<cr:CrystalReportsViewer x:Name="crv" />
</DockPanel>
C#:
rptOnlinePayment rpt = new rptOnlinePayment();
rpt.SetDataSource(ds);
SAPBusinessObjects.WPF.Viewer.ViewerCore view = crv.ViewerCore;
view.ReportSource = rpt;
Edited by: les_IronData on Nov 15, 2010 2:30 PM
Edited by: Don Williams on Nov 15, 2010 5:46 AM
Edited by: Ludek Uher on Nov 16, 2010 3:44 PM
Then I get the following error:
System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=SAPBusinessObjects.WPF.ViewerShared
StackTrace:
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 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at TrafficManagement.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've narrowed down specific scenario:
When I create a new Crystal Report WPF Application project, and just create a blank report everything works. When I change the application to a class library and include it as a reference to an existing project, instantiate the viewer in a xaml window, that is when I get the error. Can we not run the Crystal Reports WPF Viewer from a referenced assembly?
This error only occurs if i include the referenced assembly containing my crystal report/viewer in my current project. I created a new project and referenced the report project and it works fine. I have checked all of my references and they are all pointing to the right version of CR. Not sure if this matters, but everytime I start my project, I get the Crystal Reports Project Conversion dialog box saying that my solution was created using an older or unkown version of CR. I run the conversion everytime I open the project. Also, in my current Windows Forms report viewers I get an error:
*
System.TypeInitializationException was unhandled
Message=The type initializer for 'CrystalDecisions.ReportSource.ReportSourceFactory' threw an exception.
Source=CrystalDecisions.Windows.Forms
TypeName=CrystalDecisions.ReportSource.ReportSourceFactory
StackTrace:
at CrystalDecisions.Windows.Forms.CrystalReportViewer..ctor()
at TrafficManagement.frmViewDailyRectListing.InitializeComponent() in C:\SVN\Traffic\Forms\Report Viewers\frmViewDailyRectListing.vb:line 51
at TrafficManagement.frmViewDailyRectListing..ctor(DateTime datFrom, DateTime datTo, String entity, Int32 rectEnt, String rectEntDesc) in C:\SVN\Traffic\Forms\Report Viewers\frmViewDailyRectListing.vb:line 23
at TrafficManagement.frmRectMenu.btnDailyRectListing_Click(Object sender, EventArgs e) in C:\SVN\Traffic\Forms\Menus\frmRectMenu.vb:line 783
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.PerformClick()
at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at TrafficManagement.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
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: System.TypeInitializationException
Message=The type initializer for 'CrystalDecisions.Shared.SharedUtils' threw an exception.
Source=CrystalDecisions.Shared
TypeName=CrystalDecisions.Shared.SharedUtils
StackTrace:
at CrystalDecisions.Shared.SharedUtils.GetFullTypeName(Type type)
at CrystalDecisions.ReportSource.ReportSourceFactory..cctor()
InnerException: System.IO.FileNotFoundException
FileName=log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821
FusionLog==== Pre-bind state information ===
LOG: User = VISTAPC\Les
LOG: DisplayName = log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821
(Fully-specified)
LOG: Appbase = file:///C:/SVN/Traffic/bin/
LOG: Initial PrivatePath = NULL
Calling assembly : CrystalDecisions.Shared, Version=14.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\SVN\Traffic\bin\Traffic.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821
LOG: Attempting download of new URL file:///C:/SVN/Traffic/bin/log4net.DLL.
LOG: Attempting download of new URL file:///C:/SVN/Traffic/bin/log4net/log4net.DLL.
LOG: Attempting download of new URL file:///C:/SVN/Traffic/bin/log4net.EXE.
LOG: Attempting download of new URL file:///C:/SVN/Traffic/bin/log4net/log4net.EXE.
Message=Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The system cannot find the file specified.
Source=CrystalDecisions.Shared
StackTrace:
at CrystalDecisions.Shared.SharedUtils..cctor()
InnerException:
*
Why is this asking for reference to log4net?
You are using Beta of CRVS2010. From the error:
Initial PrivatePath = NULL Calling assembly : CrystalDecisions.Shared, Version=14.0.2000.0,
I'd recommend that you uninstall the Beta and install the GA of CRVS2010:
/people/coy.yonce/blog/2010/11/12/crystal-reports-for-visual-studio-2010-production-release-now-availableCystlR%2528SAPWeblogs%253ACrystal+Reports%2529
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]
I alleviated references to the version 14 beta stuff by completely re-imaging my system (reinstalled windows, VS 2010, CRVS2010) but am still having a problem with adding a class library that uses wpf forms with WPF report viewer to a windows forms project. I was able to duplicate the process with the following steps:
1) Create a windows forms project using .NET Framework 4 as target framework.
2) Add a WPF Windows application project
3) Add a WPF CrystalReportViewer to the window in WPF project
4) Add a blank strong typed CrystalReport to the WPF Project
5) Change the Output type of the WPF project to Class Library
6) In the windows forms project, from Form1 add a button with click event instantiating a MainWindow from the WPF project and call ShowDialog()
7) In the MainWindow add a button with click event instantiating a Window1 object that contains the CrystalReportViewer (name 'crv') object and call ShowDialog()
😎 Add a crystalReport to the project (blank report) named CrystalReport1
9) Create a window_loaded event handler and add the following code to Window1 code behind:
crv.ViewerCore.ReportSource = new CrystalReport1();
When that project runs and you click thru the buttons on the forms you should get the following error:
*
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=SAPBusinessObjects.WPF.ViewerShared
StackTrace:
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.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.Show()
at System.Windows.Window.ShowDialog()
at WpfReports.MainWindow.button1_Click(Object sender, RoutedEventArgs e) in c:\users\les\documents\visual studio 2010\Projects\WinFormsCRTest\WpfReports\MainWindow.xaml.cs:line 30
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(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.Window.ShowHelper(Object booleanBox)
at System.Windows.Window.Show()
at System.Windows.Window.ShowDialog()
InnerException:
*
I can provide the source code for this project if needed. I don't see how to attach a file in this forum however. Thank YOu.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.