2011-11-15 11 views
0

現在、複数のレポートを使用しているため、ユーザーがWPFアプリケーションのコンテキストメニューから項目を選択すると、報告例コンテキストメニューから毎週を選択した場合は、週次レポートをレポートフォームに表示する必要があります。WPFプロジェクト内から複数のレポートを同じソリューションで呼び出すと、C#レポートエラーが発生する

コンパイル時エラーは発生しませんでしたが、レポートビューアに次のように表示されます。 "ローカルレポート処理中にエラーが発生しました。レポート 'Reports.Report3.rdlc'のレポート定義が指定されていません。 WPFアプリケーションのコンテキストメニュー項目

Reports.Form1 Reports = new Reports.Form1(); 
       Reports.reportViewer1.Reset(); 
       Reports.reportViewer1.LocalReport.DataSources.Clear(); 
       ReportDataSource reportDataSource1 = new ReportDataSource(); 
       Reports.SpecificationsTableAdapter.Fill(Reports.RocketToolsDataSet.Specifications); 
       reportDataSource1.Name = "TestDataSet"; 
       reportDataSource1.Value = Reports.SpecificationsBindingSource; 
       Reports.reportViewer1.LocalReport.DataSources.Add(reportDataSource1); 
       Reports.reportViewer1.LocalReport.ReportEmbeddedResource = "Reports.Report3.rdlc"; 
       Reports.reportViewer1.Name = "reportViewer1"; 
       Reports.reportViewer1.RefreshReport(); 
       Reports.Show(); 
       loading.Close(); 

レポートフォームのプロジェクト名が呼ばれたレポートやプロジェクト名をクリックすると、私は以下のコードを使用してい

がRocketToolsと呼ばれています。私は自分のWPFプロジェクト内でReportsプロジェクトを参照しました。レポートがレポート・フォーム内のロード時のデフォルト設定であれば、正常にロードされます。しかし、フォームをWPFアプリケーション内でロードする設定を変更しようとすると、上記のエラーが発生します。

誰かが私を助けることができますしてください

答えて

0

はwindowsformhostingを使用してではなく、別のプロジェクトを参照することで、問題を解決しました。

XAMLコードは以下のように表示され、プロジェクトに新しいアイテムを追加し、レポートウィンドウのインスタンスを作成するときに元の質問のコードを使用して、手動でテーブルアダプタとデータセットを作成できます。

<Window x:Class="RocketTools.Reports" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:viewer="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms" 
     Title="Reports" Height="691" Width="1117" Loaded="Window_Loaded" Closed="Window_Closed" WindowStartupLocation="CenterOwner"> 
    <Grid x:Name="ReportGrid"> 
     <WindowsFormsHost Margin="12" Name="windowsFormsHost1"> 
      <viewer:ReportViewer x:Name="viewerInstance"></viewer:ReportViewer> 
     </WindowsFormsHost> 
    </Grid> </Window> 
関連する問題