How to Implement Syncfusion License in Blazor Application when license key is defined in Yaml file?

I am newbie in Syncfusion and Blazor as well and I been trying this for couple of weeks now, sadly I already used-up what I know and somehow frustrates me for I'm not getting it right. So I posted in this thread and take my chances if someone with a good heart could perhaps help or guide me to solve this. Thank you in advance.

This is the Syncfusion license key defined in my github/yml file.


Issue:

I made several attempts to get the license key to be called in Blazor program.cs but I was not able to get it.. it returns blank/null when I ran and debug the solution.

 I'm not quite sure if the code is working because its not showing an error.

here's the code snippet in program.cs

var configuration = new ConfigurationBuilder().AddYamlFile("azure-static-web-apps.yml",optional: true).Build();var env = "Development";var keylicense = configuration[env][0].ToString();//var keylicense = configuration[env]["licesene"].ToString();Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(keylicense);




1 Reply

BH BharatRam Harikrishnan Syncfusion Team January 27, 2023 01:01 PM UTC

Hi Von,


It seems in `Program.cs`, you missed to provide .yml file with base path inside the AddYamlFile() method as parameter, like this:


Or else pass the base path to SetBasePath() as below by using "Directory.GetCurrentDirectory()", like this:


And then to read a value from the YAML file, use the GetValue method of the IConfiguration object, like this:


Reference - https://blog.kloud.com.au/2017/01/25/adding-yaml-settings-into-aspnet-core-apps/


Please find the sample for reference,

https://www.syncfusion.com/downloads/support/directtrac/general/ze/SampleYml-1344916665


Regards,

Bharat Ram H


Loader.
Up arrow icon