Alexander Alexander - 8 days ago 7
C# Question

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

I have an app and it works on my computer just fine, but when I copy it to another laptop and I try to open a window with a windows forms host with a report viewer in the WinForms host, the app crashes.

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


In my code behind I don't have anything related to the WinForms host except an empty

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

}


These are my references:
enter image description here

Can someone help ?

Answer

I suppose you need to install Report Viewer Redistributable.

There are some different version, choose the version you need.

Deploying Reports and ReportViewer Controls

Microsoft Report Viewer Redistributable 2008

Comments