System.ComponentModel.LicenseManager.LicenseInteropHelper.AllocateAndValidateLicense C# (CSharp) Method

AllocateAndValidateLicense() private static method

private static AllocateAndValidateLicense ( RuntimeTypeHandle rth, IntPtr bstrKey, int fDesignTime ) : object
rth System.RuntimeTypeHandle
bstrKey System.IntPtr
fDesignTime int
return object
            private static object AllocateAndValidateLicense(RuntimeTypeHandle rth, IntPtr bstrKey, int fDesignTime)
            {
                Type type = Type.GetTypeFromHandle(rth);
                CLRLicenseContext licensecontext = new CLRLicenseContext(fDesignTime != 0 ? LicenseUsageMode.Designtime : LicenseUsageMode.Runtime, type);
                if (fDesignTime == 0 && bstrKey != (IntPtr)0)
                {
                    licensecontext.SetSavedLicenseKey(type, Marshal.PtrToStringBSTR(bstrKey));
                }


                try
                {
                    return LicenseManager.CreateWithContext(type, licensecontext);
                }
                catch (LicenseException lexp)
                {
                    throw new COMException(lexp.Message, CLASS_E_NOTLICENSED);
                }
            }