Register Syncfusion License key in Xamarin application
25 Nov 20243 minutes to read
The generated license key is just a string that needs to be registered before any Syncfusion control is initiated. The following code is used to register the license.
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");
NOTE
- Place the license key between double quotes. Also, ensure that Syncfusion.Licensing.dll is referenced in your project where the license key is being registered.
- Syncfusion license validation is done offline during application execution and does not require internet access. Apps registered with a Syncfusion license key can be deployed on any system that does not have an internet connection.
IMPORTANT
Syncfusion license keys can be validated during the Continuous Integration (CI) processes to ensure proper licensing and prevent licensing errors during deployment. Refer to the CI License Validation section for detailed instructions on how to implement it.
Xamarin.Forms
You can register the license key in App.xaml.cs constructor before InitializeComponent(). If App constructor not available in App.xaml.cs, create the “App()” constructor in App.xaml.cs and register the license key inside the constructor.
public App()
{
//Register Syncfusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");
InitializeComponent();
MainPage = new App1.MainPage();
}
If you are developing an application using Gorilla Player SDK, it is must to register the Syncfusion license key in Xamarin.Forms.Android, Xamarin.Forms.iOS, and Xamarin.Forms.UWP.
Xamarin.Forms.Android
Register the license key in OnCreate override method of your main activity class before initializing any Syncfusion control.
protected override void OnCreate(Bundle savedInstanceState)
{
//Register Syncfusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
}
Xamarin.Forms.iOS
Register the license key in FinishedLaunching override method of AppDelegate.cs
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
//Register Syncfusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");
// create a new window instance based on the screen size
Window = new UIWindow(UIScreen.MainScreen.Bounds);
// If you have defined a root view controller, set it here:
// Window.RootViewController = myViewController;
// make the window visible
Window.MakeKeyAndVisible();
return true;
}
Xamarin.Forms.UWP
Register the license key in App.xaml.cs constructor before InitializeComponent() in C#. If App constructor not available in App.xaml.cs, create the “App()” constructor in App.xaml.cs and register the license key inside the constructor. In Visual Basic, register the licensing code in App.xaml.vb file before OnLaunched event.
public App()
{
//Register Syncfusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");
this.InitializeComponent();
this.Suspending += OnSuspending;
}
Public Sub New()
'Register Syncfusion License
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY")
End Sub
Protected Overrides Sub OnLaunched(e As Windows.ApplicationModel.Activation.LaunchActivatedEventArgs)
...
End Sub
If you are using Prism Framework in your application, register the license key before InitializeComponent in OnInitialized method of App.Xaml.cs
protected override async void OnInitialized()
{
//Register Syncfusion license
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");
InitializeComponent();
await NavigationService.NavigateAsync("NavigationPage/MainPage");
}
NOTE
Refer to this link for common licensing errors