iText pdf library
Website search

Why do I get an "System.IO.FileLoadException: Could not load file or assembly" error?

In my .NET project I get an "System.IO.FileLoadException: Could not load file or assembly" error. What could be causing this?

In my .NET project I get an "System.IO.FileLoadException: Could not load file or assembly" error. What could be causing this?

This is probably because you have an strong-named assembly which has not been redirected. iText 7 has add-ons which can be released separately from releases of the core library, and so may contain references to a different version of the library than the one you are using.

Fortunately, a feature was introduced in .NET Framework 4.5.1 called Automatic Binding Redirect Generation which can automatically resolve this issue. As of .NET 4.5.1 binding redirection should work out of the box, and Visual Studio will usually add the required lines to your project file even for earlier versions. However, depending on your project or your Visual Studio settings this feature may be turned off, so you may need to add them manually.

If you're using strong-named assemblies, check if the following lines exist in your project file (.csproj). If they do not exist, try adding them to resolve the FileLoadException error:

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> 
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

By setting these two flags, your project should now load the correct iText library version.

We hope this information has been helpful.



お問い合わせ

それでも問題が解決しませんか? 

お寄せいただいたご質問には、喜んでお答えいたします。当社へご連絡ください。内容を確認次第、追ってご連絡いたします。

問い合わせる
常に最新情報を得る

11,000人以上の購読者に加わって、iTextの新しい製品、アップデート、ヒント、記述的な解決策や出来事に関する最新情報を得ることでiText PDF専門家になりましょう。

今すぐ購読