You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin跨平台项目无法安装iTextSharp相关包求助

Fixing iTextSharp Package Installation Failure in Xamarin.iOS

Hey there, fellow Xamarin newbie! I totally get how frustrating it is when you can't install a package you need—let's break down this issue and fix it.

First, let's unpack the error you're hitting:

Install-Package : NU1202: Package iTextSharp-LGPL-BouncyCastle 4.1.6 is not compatible with xamarinios10 (Xamarin.iOS,Version=v1.0). Package iTextSharp-LGPL-BouncyCastle 4.1.6 supports: - net (.NETFramework,Version=v0.0) - net20 (.NETFramework,Version=v2.0)

That old 4.1.6 version of iTextSharp-LGPL-BouncyCastle was built only for .NET Framework 2.0, which is way too outdated to work with modern Xamarin.iOS projects. It doesn't recognize Xamarin.iOS as a supported target platform at all.

Here's what you can do to get up and running:

1. Switch to the modern, Xamarin-compatible iText 7 (Recommended)

The official iText team has moved to iText 7, which is fully compatible with .NET Standard (and thus all Xamarin platforms). It's a complete rewrite with better documentation and active support. To install the packages you need:

  • For core PDF functionality, run this in the Package Manager Console:
    Install-Package itext7
    
  • If you need encryption/signing features (the equivalent of the BouncyCastle part in the old package), add this:
    Install-Package itext7.bouncy-castle-adapter
    

Note: The API is different from iTextSharp, but the official docs have plenty of guides to help you make the switch smoothly.

2. If you absolutely must use the old iTextSharp (Not Recommended)

If you're tied to the old iTextSharp API for legacy reasons, you have two hacky options:

  • Look for third-party-maintained packages that have been recompiled for Xamarin.iOS. Just be warned—these are often unmaintained and could have security gaps.
  • Download the source code of iTextSharp-LGPL and BouncyCastle, then manually compile them targeting your Xamarin.iOS platform. This requires more coding know-how, so only go this route if you're comfortable building projects from source.

3. Double-check your project's target framework

Make sure your Xamarin.iOS project is targeting a reasonably modern iOS version (iOS 12 or newer). Outdated target frameworks can sometimes cause unnecessary compatibility issues. You can adjust this in your project's properties under the "iOS Application" tab.

内容的提问来源于stack exchange,提问作者Subrata Mitra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:57:05