作成日: 2025/05/21 最終更新日: 2026/01/23
文書種別
使用方法
詳細
ActiveReportsを使用しているアプリケーションを実行したとき、System.***アセンブリのFileLoadExceptionやFileNotFoundExceptionを基点とする例外が発生する場合があります。
System.TypeInitializationException: 'GrapeCity.Documents.Q.atm' のタイプ初期化子が例外をスローしました。
---> System.IO.FileLoadException: ファイルまたはアセンブリ 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'、またはその依存関係の 1 つが読み込めませんでした。見つかったアセンブリのマニフェスト定義はアセンブリ参照に一致しません。
また、アプリケーションの構成やVisual Studioのオプション設定によっては、例外をキャッチできず、結果のみが不正となる場合があります。
具体的には以下のような問題が発生します。
- 画像を含むレポートをPDFにエクスポートしたとき、画像が表示されない
この例外は複数の要因で発生する可能性があります。以下をご確認ください。
NuGetパッケージがインストールされていない
パッケージの管理形式がpackages.config形式のプロジェクトでは、ActiveReportsの依存関係に含まれるパッケージが自動ではインストールされない場合があります。
例外の基点になっているアセンブリと同名のパッケージがpackages.configファイルに含まれているか、ご確認ください。
◆packages.configの設定例
<package id="System.Buffers" version="4.6.0" targetFramework="net481" />
<package id="System.Memory" version="4.6.0" targetFramework="net481" />
<package id="System.Numerics.Vectors" version="4.6.0" targetFramework="net481" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.0" targetFramework="net481" />
<package id="System.Text.Encodings.Web" version="6.0.0" targetFramework="net481" />
<package id="System.Text.Json" version="6.0.10" targetFramework="net481" />
<package id="System.Threading.Tasks.Extensions" version="4.6.0" targetFramework="net481" />
<package id="System.ValueTuple" version="4.5.0" 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.4.0" newVersion="4.0.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.5.0" newVersion="4.1.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
</dependentAssembly>
</assemblyBinding>上記で設定しているバージョンはNuGetパッケージの以下のバージョンに対応しています。
NuGetのバージョン |
アセンブリバージョン |
|
|---|---|---|
| System.Buffers | 4.6.0 |
4.0.4.0 |
| System.Memory | 4.6.0 |
4.0.2.0 |
| System.Numerics.Vectors | 4.6.0 |
4.1.5.0 |
| System.Threading.Tasks.Extensions | 4.6.0 |
4.2.1.0 |
| System.Runtime.CompilerServices.Unsafe | 6.1.0 |
6.0.1.0 |
異なるバージョンのNuGetパッケージを利用している場合は、対応するアセンブリのバージョンを確認し、リダイレクト先のバージョンを変更してください。
exe.configファイルを配布していない
Windowsフォームアプリやコンソールアプリの場合、プロジェクトをビルドしたときに前述のリダイレクト設定がexe.configファイルにコピーされます。
このexe.configファイルは実行環境にも配布する必要があります。
exeファイルと同一階層に配置してください。
◆参考情報