0

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 ?

Alexander
  • 405
  • 7
  • 17
  • I would say catch the exception or catch all unhandled exceptions and log the exception details so that you can see what is causing the crashes. There can be a lot of reasons on why your app crashes. Maybe have a look at this post on how to catch all unhandled exceptions http://stackoverflow.com/questions/5762526/how-can-i-make-something-that-catches-all-unhandled-exceptions-in-a-winforms-a – Bracher Nov 24 '16 at 17:50
  • have you installed reportviewer client? – McNets Nov 24 '16 at 19:17
  • you mean have I installed report viewer on the client machine also?not only on mine? – Alexander Nov 24 '16 at 19:22
  • there is a redistributable viewer – McNets Nov 24 '16 at 19:23
  • just take care with the version you used – McNets Nov 24 '16 at 19:23
  • would this eliminate the exception "the invocation of the constructor on type microsoft reporting winforms reportviewer that matches the specified binding constraints" ? – Alexander Nov 24 '16 at 19:58

1 Answers1

2

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

McNets
  • 10,352
  • 3
  • 32
  • 61
  • I need to instal this on a laptop? I mean,on every clint pc,that I put my app on? – Alexander Nov 24 '16 at 19:25
  • Since I don't have an installer,I only copy my files from debug folder..I can use this redistributalbe instal,and it will work fine? – Alexander Nov 24 '16 at 19:30