Activated License always shows null in the init

Hi Support,

I am using Xprotect Proffessional 2017 R1 application. And Ihave created one plugin and I want to intigrate with license .But unfortunately it works when I do online activation but once i close the application and on reopen it always going to trial mode instead of licensed mode.can you please assist me in this?

In my Code: (in MyPlugIn.Admin)

internal static void Init()

{

  \_regLicenseReceiver = EnvironmentManager.Instance.RegisterReceiver(NewLicense,

                                    new MessageIdFilter(

                                    MessageId.System.LicenseChangedIndication));

  // Get the activated license, if available

  \_activatedServerLicense = EnvironmentManager.Instance.LicenseManager.GetLicense(

    MyPlugInDefinition.MyPlugInPluginId,

    MyPlugInDefinition.MyPlugInLicenseID);

  // Get the stored license, that is either a copy of the activated one, or a TrialMode one as filled below. 

  \_myServerLicense = EnvironmentManager.Instance.LicenseManager.ReservedLicenseManager.GetLicenseInformation(

    MyPlugInDefinition.MyPlugInPluginId,

    MyPlugInDefinition.MyPlugInLicenseID);

  // If real license already activated, use that one as a starting point

  if (\_activatedServerLicense != null)

    \_myServerLicense = \_activatedServerLicense;

  else

  {

    // If no license is available, store today + 30 days as the trial period

    \_myServerLicense = new LicenseInformation()

    {

      PluginId = MyPlugInDefinition.MyPlugInPluginId,

      Counter = 1,

      CustomData = "Here we can add some custom data",

      LicenseType = MyPlugInDefinition.MyPlugInLicenseID,

      Name = "MyPlugIn",

      Expire = DateTime.UtcNow + TimeSpan.FromDays(30),

      TrialMode = true,

      ItemIdentifications = new System.Collections.ObjectModel.Collection<LicenseItem>()

    };

  }

  if (EnvironmentManager.Instance.EnvironmentType == EnvironmentType.Administration)

  {

    EnvironmentManager.Instance.LicenseManager.ReservedLicenseManager.SaveLicenseInformation(\_myServerLicense);

  }

  \_initialized = true;

}

_activatedServerLicense always returns NULL, so the System always Creates a Trial License.

You might me calling your static Init method before the environment is fully initialized. Try calling it from your override of ItemManager.Init.

Yes I am calling LicenseManager.Init() in the ItemManager.Init itself but still it shows null.

My plugin contains Administartor as well as background plugin code.Is that makes any difference?