作成日: 2026/03/25 最終更新日: 2026/03/25
文書種別
使用方法
詳細
ActiveReportsを使用しているアプリケーションを実行したとき、System.***アセンブリのFileLoadExceptionやFileNotFoundExceptionを基点とする例外が発生する場合があります。
◆エクスポート処理で発生する例外
'GrapeCity.Documents.Q.aoa' のタイプ初期化子が例外をスローしました。
内部例外 1:
TypeInitializationException: 'GrapeCity.Documents.Q.atm' のタイプ初期化子が例外をスローしました。内部例外 2:
FileLoadException: ファイルまたはアセンブリ 'System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'、またはその依存関係の 1 つが読み込めませんでした。見つかったアセンブリのマニフェスト定義はアセンブリ参照に一致しません。
◆JSONデータソースを使用しているレポートで発生する例外
GrapeCity.ActiveReports.PageReport' のタイプ初期化子が例外をスローしました。
内部例外 1:
FileLoadException: ファイルまたはアセンブリ 'System.Text.Json, Version=8.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'、またはその依存関係の 1 つが読み込めませんでした。見つかったアセンブリのマニフェスト定義はアセンブリ参照に一致しません。
また、アプリケーションの構成やVisual Studioのオプション設定によっては、例外をキャッチできず、結果のみが不正となる場合があります。
具体的には以下のような問題が発生します。
- 画像を含むレポートをPDFにエクスポートしたとき、画像が表示されない
この例外は複数の要因で発生する可能性があります。以下をご確認ください。
NuGetパッケージがインストールされていない
パッケージの管理形式がpackages.config形式のプロジェクトでは、ActiveReportsの依存関係に含まれるパッケージが自動ではインストールされない場合があります。
例外の基点になっているアセンブリと同名のパッケージがpackages.configファイルに含まれているか、ご確認ください。
◆packages.configの設定例
<package id="System.Buffers" version="4.6.1" targetFramework="net481" />
<package id="System.IO.Pipelines" version="10.0.2" targetFramework="net481" />
<package id="System.Memory" version="4.6.3" targetFramework="net481" />
<package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net481" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net481" />
<package id="System.Text.Encodings.Web" version="10.0.2" targetFramework="net481" />
<package id="System.Text.Json" version="10.0.2" targetFramework="net481" />
<package id="System.Threading.Tasks.Extensions" version="4.6.3" targetFramework="net481" />
<package id="System.ValueTuple" version="4.6.1" targetFramework="net481" />インストールされていない場合、NuGetパッケージの再インストールをお試しください。
アセンブリバージョンのリダイレクトが設定されていない
NuGetパッケージの依存関係にはバージョンが競合するものが含まれているため、リダイレクト設定(bindingRedirect)が必要になります。
プロジェクトにNuGetパッケージをインストールすると、App.configファイルやWeb.configファイルにリダイレクト設定が自動的に追加されます。
ただし、Visual Studioのオプションで「バインディング リダイレクトの適用をスキップする」を有効にしている場合はリダイレクト設定が追加されません。
リダイレクト設定が不足している場合は、スキップを無効にした状態でパッケージを再インストールするか、configファイルを手動で編集してください。
◆設定例
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.6.0" newVersion="4.1.6.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.2" newVersion="10.0.0.2" />
</dependentAssembly>
</assemblyBinding>上記で設定しているバージョンはNuGetパッケージの以下のバージョンに対応しています。
NuGetのバージョン |
アセンブリバージョン |
|
|---|---|---|
| System.Buffers | 4.6.1 |
4.0.5.0 |
| System.Memory | 4.6.3 |
4.0.5.0 |
| System.Numerics.Vectors | 4.6.1 |
4.1.6.0 |
| System.Runtime.CompilerServices.Unsafe | 6.1.2 |
6.0.3.0 |
| System.Text.Json | 10.0.2 |
10.0.0.2 |
異なるバージョンのNuGetパッケージを利用している場合は、対応するアセンブリのバージョンを確認し、リダイレクト先のバージョンを変更してください。
exe.configファイルを配布していない
Windowsフォームアプリやコンソールアプリの場合、プロジェクトをビルドしたときに前述のリダイレクト設定がexe.configファイルにコピーされます。
このexe.configファイルは実行環境にも配布する必要があります。
exeファイルと同一階層に配置してください。
◆参考情報
アセンブリ バージョンのリダイレクト - .NET Framework | Microsoft Learn
構成ファイルを使用してアプリを構成する方法 - .NET Framework | Microsoft Learn