当我使用 windowsformhost 和 reportviewer 打开 window 时,wpf 在另一台计算机上崩溃

wpf crashes on another computer when I open a window with windowsformhost and reportviewer

我有一个应用程序,它在我的电脑上运行得很好,但是当我将它复制到另一台笔记本电脑时,我尝试打开一个 window 和一个 windows 带有报表查看器的表单主机在 WinForms 主机中,应用程序崩溃。

我的XAML:

<Window x:Class="Zavod.Izvestaji.Izvestaj02"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:rv="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Zavod.Izvestaji"
    mc:Ignorable="d"
    Title="Завод за заштиту споменика културе у Панчеву" 
    Height="677.188" Width="837.317" 
    ResizeMode="CanMinimize" 
    WindowStartupLocation="CenterScreen" 
    FontFamily="Verdana" 
    Background="#FFA38566">

    <Grid>

        <WindowsFormsHost Margin="0,84,0,0">
            <rv:ReportViewer x:Name="reportViewerObrazac02" 
                RenderingComplete="reportViewer_RenderingComplete" />
        </WindowsFormsHost>

        <TextBox x:Name="textBoxObjekat" 
            HorizontalAlignment="Left"
            Height="23" Width="223"
            Margin="168,32,0,0" 
            TextWrapping="Wrap" 
            VerticalAlignment="Top"  
            IsEnabled="False"/>

        <Button x:Name="buttonIzaberiObjekat" 
            Content="Изаберите објекат" 
            HorizontalAlignment="Left" 
            Margin="396,34,0,0" 
            VerticalAlignment="Top" 
            Click="buttonIzaberiObjekat_Click" />

        <Button x:Name="buttonIzvestaj" 
            Content="Генериши извештај" 
            HorizontalAlignment="Left" 
            Margin="548,34,0,0" 
            VerticalAlignment="Top" 
            Click="buttonIzvestaj_Click" />

    </Grid>
</Window>

在我后面的代码中,我没有任何与 WinForms 主机相关的内容,除了一个空

private void reportViewer_RenderingComplete(object sender,
    Microsoft.Reporting.WinForms.RenderingCompleteEventArgs e)
{

}

这些是我的参考资料:

有人可以帮忙吗?

我想您需要安装 Report Viewer Redistributable。

有一些不同的版本,选择你需要的版本。

Deploying Reports and ReportViewer Controls

Microsoft Report Viewer Redistributable 2008