0

LicenseKey.LoadLicenseFile is not working for sharepoint project.

When I create a console tool and add itext.licesekey.dll manually, the pdf file is generated without license. But if I add it by PM command Install-Package itext7.licensekey, it works correctly.

Do you have any idea why this could happen?

Thanks in advance, Toan

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101

2 Answers2

3

There are 2 possible reasons why this is happening:

  1. You're using the wrong version of the license key library which is used for checking your license file. For iText 5, that library is called itextsharp.licensekey.dll and has a root namespace of iTextSharp. For iText 7, on the other hand, it is called itext.licensekey.dll and has a root namespace of itext. The NuGet package at https://www.nuget.org/packages/itext7.licensekey, which you installed with PM command Install-Package itext7.licensekey, is the correct license key library for your iText 7 license.

  2. Your manually added license key library is correct, but you didn't add it in the right way so that your project knows where to find it. That is the convenience of the NuGet Package Manager: it makes sure that your libraries are added in the right way. I have never used .NET myself so I can't go into details, but to my understanding, NuGet is sort of like the Maven of the .NET world, as far as dependency management is concerned.

By the way, because you are an iText customer with a valid license key, you probably also have a support contract, and you should ask questions about your license in the iText JIRA. I can't find your login based on your name, every customer can register up to 3 contacts that are eligible for support. Please check with the person in your company who purchased the iText license.

Or you are using a time limited trial license, in which case you can also contact iText Sales for questions about the license.

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
  • Hi Amedee Van Gasse, I figured out that if I load dll(itext.licensekey.dll) from GAC, it doesn't work. Do you know the different between load from GAC and local? I deployed correct dll (itext.licensekey.dll) to gac Thanks, Toan – Toan Nguyen Nov 22 '16 at 10:02
  • Please open a support ticket. – Amedee Van Gasse Nov 22 '16 at 12:08
0

I have decompiled the itext dlls and figure out in iText.Kernel.Version class, method GetInstance:

string str = "iText.License.LicenseKey, itext.licensekey";
string str1 = "GetLicenseeInfo";
Type type = Type.GetType(str);
if (type == null)
{
    Version.version.AddAGPLPostfix(null);
}

The variable type was null. Please check here for more information how to get dll from GAC The solution should look like that I guess the correct string should be like this

string str = "iText.License.LicenseKey, itext.licensekey, Version=2.0.2.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca";
Community
  • 1
  • 1
  • There is no need to decompile, you can find the source at https://github.com/itext/itext7-dotnet/blob/develop/itext/itext.kernel/itext/kernel/Version.cs – Amedee Van Gasse Dec 01 '16 at 11:20