Hello Nikolay,
I am going to provide a simple way to check to see if the NetAdvantage for Windows Forms controls are licensed to be used at design time on the computer. For this I have made the following assumptions:
- You are referring to Windows Forms as you said "form designer".
- The NetAdvantage assemblies are already referenced by your product so they are present.
- You are only looking for a single version on the developers machine that matches the version your product uses.
If these assumptions are correct then you can use the LicenseManager to check the license of a NetAdvantage Control after setting the CurrentContext to a LicenseContext that has a UsageMode of DesignTime. If this doesn't throw any exceptions and UltraLicense is returned that has ProductInfo.Status set to LicenseStatus.Licensed then the machine has a license to use the NetAdvantage controls at design time. After this check the CurrentContext needs to be resotred to the correct context. The following code is an example of what you might use to do this:
class LicenseChecker
{
public static bool IsInfragisticsWindowsFormsDesignTimeAllowed()
{
UltraButton button = new UltraButton();
Type ultraButtonType = typeof(Infragistics.Win.Misc.UltraButton);
LicenseContext context = new TestLicenseContext();
LicenseContext currentContext = LicenseManager.CurrentContext;
License license = null;
LicenseManager.CurrentContext = context;
try
{
LicenseManager.IsValid(ultraButtonType, button, out license);
}
catch (Exception)
{
return false;
}
LicenseManager.CurrentContext = currentContext;
UltraLicense ultraLicense = license as UltraLicense;
button.Dispose();
return ultraLicense != null && ultraLicense.ProductInfo.Status == LicenseStatus.Licensed;
}
}
public class TestLicenseContext : LicenseContext
{
public override LicenseUsageMode UsageMode
{
get
{
return LicenseUsageMode.Designtime;
}
}
}
I have also attached a simple sample that you can reference that demonstrates this. Simply compile the sample and run it on a machine that has NetAdvantage for Windows Forms installed and one that doesn't to see the difference in behavior.
If the assumptions that I have made are not valid for you, please provide more detail on what you need so that I can look into this further.
Let me know if you have any questions.