How to Initialize License file of Aspose?
License initialization can be done in the Global.asax file or you can put the code in the constructor of your class, which you are using for the generation of your excel report.
Codes:
Here my class name is ReportBuilder. I have put the Aspose.lic file in a folder "License" in my project. I have written the path in a .cs file name AppConstant to avoid hard coding in project and i am using it here.
Note:
Write the path in the AppConstant file like this
public const string ASPOSE_LICENSE_PATH = ".License.Aspose.Total.lic";
public ReportBuilder()
{
string fileKey = string.Concat(this.GetType().Namespace, AppConstant.ASPOSE_LICENSE_PATH);
Stream file = Assembly.GetExecutingAssembly().GetManifestResourceStream(fileKey);
Aspose.Cells.License cellsLicense = new Aspose.Cells.License();
cellsLicense.SetLicense(file);
}
First i am assigning the path to a string variable filekey. Now i am getting the Project directory of the server by the code this.GetType().Namespace and by concatenation i am getting the full path of the license file. Then i am converting the file to MemoryStream object and setting the license. SetLicense() method supports other over loads also. For my convenience i have used like that.
Another important thing here is set the BuildAction of the "Aspose.license" file to "Embedded Resource" instead of "None"
How to do this?
Right click on the Aspose.license file , go to property, now set the BuildAction to Embedded Resource.
So setting license file for Aspose is done.
Dot Net Knowledge: Initialize License File Of Aspose >>>>> Download Now
ReplyDelete>>>>> Download Full
Dot Net Knowledge: Initialize License File Of Aspose >>>>> Download LINK
>>>>> Download Now
Dot Net Knowledge: Initialize License File Of Aspose >>>>> Download Full
>>>>> Download LINK yH