我有一个菜单项在打开一个新窗口的大程序中。没有任何东西会被传入,它会加载一个日历,3个空文本框,3个标签,2个按钮和一个空的Crystal Report Viewer。初始化组件会抛出一个空引用异常
当其运行用户单击日历时,会自动将所选月份的第一个和最后一个日期插入到2个文本框中。一个按钮用数据库中的数据加载CR报告,另一个按钮打印报告。
这对我的系统工作正常,但在同事系统上部署时,Initialize Component会引发空引用异常。我无法在我的系统上重新创建例外。
有人有什么想法,甚至应该从哪里开始?
更新
ERROR
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Baml2006.Baml2006Reader.Process_PropertyWithConverter()
at System.Windows.Baml2006.Baml2006Reader.Process_OneBamlRecord()
at System.Windows.Baml2006.Baml2006Reader.Process_BamlRecords()
at System.Windows.Baml2006.Baml2006Reader.Read()
at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at KeyInScreen.RebatesReports.InitializeComponent()
at KeyInScreen.RebatesReports..ctor()
at KeyInScreen.Menu.FertiliserRebate_Click(Object sender, RoutedEventArgs e)
XAML代码
<Window x:Class="KeyInScreen.RebatesReports"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Fertiliser Rebates" WindowState="Maximized"
xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer"
mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="700"
Width="1350">
<Window.Resources>
<Style TargetType="{x:Type Label}">
<Setter Property="FontSize" Value="14" />
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="14"/>
</Style>
<Style TargetType="{x:Type Calendar}">
<Setter Property="FontSize" Value="14"/>
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="FontSize" Value="14"/>
</Style>
</Window.Resources>
<Grid Background="#FFEFEDDF">
<Grid.RowDefinitions>
<RowDefinition Height=".5*"/>
<RowDefinition Height=".5*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="5*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".2*"/>
<ColumnDefinition Width=".7*"/>
<ColumnDefinition Width=".7*"/>
<ColumnDefinition Width=".7*"/>
<ColumnDefinition Width=".5*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width=".1*"/>
</Grid.ColumnDefinitions>
<Calendar x:Name="cDatePicker" Grid.Column="1" Grid.Row="2" Grid.RowSpan="2" Grid.ColumnSpan="2" SelectedDatesChanged="cDatePicker_SelectedDatesChanged" />
<Label Content="Start Date:" Grid.Column="1" Grid.Row="4" Margin="5"/>
<TextBox x:Name="txtStartDate" Grid.Column="2" Grid.Row="4" Margin="5" VerticalContentAlignment="Center" />
<Label Content="End Date:" Grid.Column="1" Grid.Row="5" Margin="5"/>
<TextBox x:Name="txtEndDate" Grid.Column="2" Grid.Row="5" Margin="5" VerticalContentAlignment="Center"/>
<Label Content="Supplier Number:" Grid.Column="1" Grid.Row="6" Margin="5"/>
<TextBox x:Name="txtCustomerNumber" Grid.Column="2" Grid.Row="6" Margin="5" VerticalContentAlignment="Center" TabIndex="1" />
<Button x:Name="btnShowRport" Content="View Report" Grid.Column="1" Grid.Row="8" Margin="0,0,10,0" Click="btnShowRport_Click" IsDefault="True" />
<Button x:Name="btnPrintReport" Content=" Print Report" Grid.Column="2" Grid.Row="8" Margin="10,0,0,0" Click="btnPrintReport_Click" />
<my:CrystalReportsViewer x:Name="crReportViewer" Grid.Column="3" Grid.RowSpan="10" HorizontalAlignment="Center" VerticalAlignment="Center"
Height="656" Width="845" Margin="94,-7,62,12" ToggleSidePanel="None" Panel.ZIndex="0" Grid.ColumnSpan="3"
ShowPrintButton="False" ShowRefreshButton="False" ShowSearchTextButton="False" ShowToggleSidePanelButton="True"
ShowToolbar="True" ShowNextPageButton="True" ShowGoToPageButton="True" ShowExportButton="False"
ShowCopyButton="False" SnapsToDevicePixels="True" ShowLogo="False" ShowPrevPageButton="True"
ShowStatusbar="True" />
</Grid>
感谢
从查看异常堆栈跟踪开始。心理调试说,可能你的窗口的Report Viewer(或其他一些重量级组件)试图在构造上执行一个iffy操作(例如,连接到一个数据源),并且这种操作在你的同事的机器上失败(无法访问服务器,无法用他的凭据登录等)。 – Jon
验证是否所有的Crystal组件都可用.. Crystal Report Viewer似乎是个罪魁祸首 – V4Vendetta
它似乎不是CR Viewer。我不太了解异常堆栈,但我认为问题出在WPF/XAMl – Noelle