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

Xamarin跨平台新手求助:无法安装ITextSharp包(VS2017 V15.6.6)

Hey there, let's work through this package installation problem step by step—since you're new to Xamarin, we'll start with the basics and move to project-specific fixes.

Troubleshooting NuGet Package Installation Issues in Visual Studio 2017 (v15.6.6) for Xamarin

First: Fix Visual Studio & NuGet Core Issues

Since you can't install any packages, the problem likely starts with your NuGet setup or VS installation:

  • Update NuGet Package Manager: Your VS 2017 version is a bit dated, and outdated NuGet is a top cause of installation failures. Head to Tools > Extensions and Updates > Updates > Visual Studio Marketplace > NuGet Package Manager and install any available updates. Restart VS after this.
  • Clear NuGet Cache: Corrupted cache files often break package installs. Go to Tools > Options > NuGet Package Manager > General and click Clear All NuGet Cache(s). Restart VS once done.
  • Verify Package Sources: Make sure the official NuGet gallery is enabled. Go to Tools > Options > NuGet Package Manager > Package Sources—check that nuget.org is listed and checked. If it's missing, add it with the URL https://api.nuget.org/v3/index.json.

Next: Specific Fixes for iTextSharp (Plus a Critical Note)

Before diving in: iTextSharp is no longer actively maintained, and it can have compatibility hiccups with modern Xamarin projects. The official, supported successor is iText 7, which works better with .NET and Xamarin. But if you specifically need iTextSharp, here's what to do:

  • Check Your Project's Target Framework: iTextSharp 5.5.13.2 (the last stable release) supports .NET Framework 2.0+, Xamarin.iOS, and Xamarin.Android. Double-check your project's target framework in the project properties to ensure it matches.
  • Install via Package Manager Console: If the GUI package installer fails, use the console for more control and clearer error messages. Open Tools > NuGet Package Manager > Package Manager Console and run:
    Install-Package iTextSharp -Version 5.5.13.2
    
    If this fails, the error message will tell you exactly what's blocking the install (like dependency conflicts).
  • Resolve Dependency Conflicts: If you get dependency errors, use the Get-Package command in the Package Manager Console to list all installed packages. Look for packages that require conflicting framework versions or clash with iTextSharp's requirements.

Then: Rule Out Project Corruption

If even simple packages won't install in your project, it might be corrupted. Try these steps:

  • Test a Blank Project: Create a new, empty Xamarin.Forms or native Xamarin project, then try installing a basic package like Newtonsoft.Json. If this works, your original project is likely damaged.
  • Repair the Original Project:
    1. Delete the packages folder in your project directory.
    2. Delete the hidden .suo file in your solution folder (you'll need to show hidden files in File Explorer).
    3. Reopen the solution, right-click the solution in Solution Explorer, and select Restore NuGet Packages.

Last Resort: Repair Visual Studio

If even new projects can't install packages, your VS 2017 installation is probably corrupted. Go to Control Panel > Programs > Programs and Features, find Microsoft Visual Studio 2017, click Change > Repair. This will fix missing or broken components.

Alternative: Switch to iText 7

If you're open to it, iText 7 is the modern, supported replacement. It's more compatible with Xamarin and gets regular updates. Install it via the Package Manager Console with:

Install-Package iTextSharp.LGPLv2.Core -Version 1.7.10

内容的提问来源于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:53:31