Oleg Kucherenko
Oleg Kucherenko

Reputation: 21

How to set TeeChart.licenses file for a plugin assembly

I use steema.teechart.net.4.2019.8.8 for WPF development. I need to specify a license in a non-exe assembly (A) which uses TChart control because I don't have an access to executing assembly (B). To do that I:

But this didn't work, I still see "This is an EVALUATION version ..." during runtime; while designtime everything is fine.

Can you please advise how to specify TeeChart.licenses not for an executing assembly, but for assembly actually using TChart?

PS:

Upvotes: 1

Views: 291

Answers (1)

Oleg Kucherenko
Oleg Kucherenko

Reputation: 21

TeeChart tutorial says there is on option to call plugin-constructor to manually pass an assembly which contains license: But this doesn’t work actually for Steema.TeeChart.WPF.TChart (as of steema.teechart.net.4.2019.8.8). I decompiled the code and verified that those plugin constructors do nothing with passed instances.

Overall license pickup process looks like following:

  1. First it checks for the first resource named “*TeeChart.licenses*” embedded in a starting assembly.
  2. Then it checks for a file named "TeeChart.licenses" in a working directory.
  3. Then in checks for a resource file “steema.resources” at starting assembly location and takes resource named “TeeChart” from there.
  4. Then in checks for a resource file “ResX\steema.resources” at starting assembly location and takes resource named “TeeChart” from there.

In my case I just created steema.resources file dynamically and embedded there the license from non-executing assembly:

    public static void FixTeeChartLicense(Assembly assembly)
    {
        var filename = "steema.resources";
        if (File.Exists(filename))
        {
            return;
        }

        var resourceName = assembly.GetManifestResourceNames().FirstOrDefault(s => s.Contains("TeeChart.licenses"));
        if (resourceName == null)
        {
            return;
        }

        using (var resourceStream = assembly.GetManifestResourceStream(resourceName))
        using (var resourceWriter = new ResourceWriter(filename))
        {
            resourceWriter.AddResource("TeeChart", resourceStream);
        }
    }

Upvotes: 1

Related Questions