ComponentInfo / GemBox.PDF - troubles with UnitTests

I’m currently writing unit tests for the GemBox.Pdf library (.NET).
I’d like to implement both positive and negative test paths for license key loading.

However, I’ve noticed that this isn’t feasible — the license key can only be loaded once, regardless of whether it’s a valid key (e.g., "FREE-LIMITED-KEY") or an invalid one (e.g., "FakeLicence").

This limitation makes it impossible to fully test both scenarios in unit tests.
For example:

  • If I load a valid key first and then an invalid one, I can still create an empty document using:
using (var document = new PdfDocument()) { } // yes, but only to check if licence is corretly 

But if I load an invalid key first and then a valid one ("FREE-LIMITED-KEY" ), the same code:

using (var document = new PdfDocument()) { }

throws an exception, as if the license was never properly loaded.

Question:
Would it be possible to expose a property or method in ComponentInfo (or elsewhere in GemBox.Pdf) that indicates whether the license was successfully loaded?

Hi Paul,

Yes, this is the expected behavior. GemBox licenses are designed to be a one-time global operation per application domain.

Regarding the suggested property, we appreciate the suggestion, but exposing license status programmatically could introduce security and abuse concerns (for example, it would simplify reverse-engineering).

Anyway, if you’re targeting .NET Framework, you could isolate license tests in a separate AppDomain.

I hope this helps.

Regards,
Mario

Thanks for reply,

Im using .NET Core (@Windows and @Docker Linux)

System.PlatformNotSupportedException : Secondary AppDomains are not supported on this platform.

Regards
Paul

Yes, the AppDomain.CreateDomain method is only supported on the .NET Framework.
I’m afraid that the only other suggestion I have is to use a separate test project for the negative path.