iTextSharp and Xamarin

2019-05-18 03:00发布

问题:

I'm trying to use iTextSharp dll in an Xamarin App, but I´m not able to compile because I´ve received this error:

Error       Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'System.Drawing.dll'
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
   at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver)   App2.Android    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets   1399    2

回答1:

You need to use Xamarin Port.

Xam.iTextSharpLGPL ( Install-Package Xam.iTextSharpLGPL)

You can download package from NuGet https://www.nuget.org/packages/Xam.iTextSharpLGPL/