Licensing (1)
Each product of e-iceblue provides a trial version, every registered user can download them from our site for free. The trial version product will add an extra sheet (in Spire.XLS) or paragraph (in Spire.Doc) with the Evaluation Warning to the result file. From Spire.Doc v3.6.0/Spire.XLS v5.8.0/Spire.Office 1.4.0, We deprecated the old username-key registeration method and use a new license file to instead. When you purchase a license, you will get a license file from us. After you apply it, the Evaluation Warning will disappear.
This section will show you what is the license file and how to apply the license file. It includes following topics:
- License File Introduction
- How to Apply the License File
- How to Include the License File as an Embedded Resource
- How to Apply the License File in a Web Site
- How to Apply the License in Silverlight
1. License File Introduction
The license file is an XML format file that contains details such as the username&email&organization of the purchaser, licensing date, product name, product version, the number of licensed developer, the number of licensed site and so on. The license file is digitally signed, so do not modify it anyway.
You need to apply it before performing any operations with our products, but it's only required once to apply the license file in an application or process.
2. How to Apply the License File
Performing any operation with our products will lead the license module to check whether the license has been loaded. If not, the license module will try to load it. The license can be loaded implicitly or explicitly from a file, stream or an embedded resource, implicit is default.
Note: Whether implicity or explicity, you must apply the license file before you call any of our products.
1). Implicit Loading
In this mode, the license module will try to search the license file in the following locations:
- The folder that contains the entry assembly (your assembly named .exe) in runtime.
- An embedded resource in the assembly that calls our product.
- The folder that contains the assembly of our product (for example: Spire.Doc.dll, Spire.XLS.dll) referenced by your assembly in runtime.
- The folder that contains the assembly that calls our product in runtime.
[C#]
//Tell the license module that you changed the license file name.
Spire.License.LicenseProvider.SetLicenseFileName("your-license-file-name");
[Visual Basic]
//Tell the license module that you changed the license file name.
Spire.License.LicenseProvider.SetLicenseFileName("your-license-file-name")
Note: The class Spire.License.LicenseProvider is defined in Spire.License.dll, which is installed to the same directory as Spire.Doc.dll/Spire.XLS.dll. It's required to reference Spire.License.dll in your project if you use the class Spire.License.LicenseProvider in your code.
You can also get the license file name by which the license module search the license, for example:
[C#]
//To get the default license file name.
String fileName = Spire.License.LicenseProvider.GetLicenseFileName();
[Visual Basic]
//To get the default license file name.
Dim fileName As String = Spire.License.LicenseProvider.GetLicenseFileName()
2). Explicit Loading
In this mode, the license module will try to load the license from a specified file or stream you provide.
- Explicitly specify the license file by a full file name.
[C#]
//Specify the license file by a full file name.
Spire.License.LicenseProvider.SetLicenseFileFullPath(@"D:\myApp\license.lic");
[Visual Basic]
//Specify the license file by a full file name.
Spire.License.LicenseProvider.SetLicenseFileFullPath("D:\myApp\license.lic")
- Explicitly specify the license file by a FileInfo object.
[C#]
//Specify the license file by a FileInfo object.
FileInfo licenseFile = new FileInfo(@"D:\myApp\license.lic");
Spire.License.LicenseProvider.SetLicenseFile(licenseFile);
[Visual Basic]
//Specify the license file by a FileInfo object.
Dim licenseFile As New FileInfo("D:\myApp\license.lic")
Spire.License.LicenseProvider.SetLicenseFile(licenseFile)
- Provide a license data stream.
[C#]
//Specify the license by a license data stream.
Stream stream = File.OpenRead(@"D:\myApp\license.lic");
Spire.License.LicenseProvider.SetLicenseFileStream(stream);
[Visual Basic]
//Specify the license by a license data stream.
Dim stream As Stream = File.OpenRead("D:\myApp\license.lic")
Spire.License.LicenseProvider.SetLicenseFileStream(stream)
3. How to Include the License File as an Embedded Resource
Including the license file as an embedded resource into one of the assemblies that calls our products is a good idea. It will make your release and deployment become easier. You don't need to worry about the loss of it any longer. To include the license file as an embedded resource in Visual Studio, perform the following steps:
- In the Solution Explorer, right-click your project and click Add | Add Existing Item... menu.
- Find your license file in the opend file browser dialog, then click the Add button to add it into your project.
- Select the file in the Solution Explorer and set Build Action to Embedded Resource in the Properties window.
- If your license file name is not the default file name license.elic.xml, invoke Spire.License.LicenseProvider.SetLicenseFileName to tell the real name to the license module in your code.

4. How to Apply the License File in a Web Site
If you want to apply the license file in a web site, just copy it into the folder Bin which contains the referenced assemblies of your web site.

5. How to Apply the License in Silverlight
In Silverlight, you must invoke the method Spire.License.LicenseProvider.SetLicenseKey(String key) to apply your license, the other methods to apply the license file are invalid in silverlight. The parameter key is the value of the Key attribute of the element License of you license xml file. To make sure that apply the license before any operation with our products, we recommend invoking this method in the App.Application_Startup method, here we suppose that the class App is SilverlightAppEntry.
[C#]
private void Application_Startup(object sender, StartupEventArgs e)
{
//Register the license key.
Spire.License.LicenseProvider.SetLicenseKey("your license key");
this.RootVisual = new MainPage();
}
[Visual Basic]
Private Sub Application_Startup(ByVal o As Object, _
ByVal e As StartupEventArgs) Handles Me.Startup
'Register the license key.
Spire.License.LicenseProvider.SetLicenseKey("your license key")
Me.RootVisual = New MainPage()
End Sub
Note: The class Spire.License.LicenseProvider is defined in Spire.License.dll, which is installed to the same directory as Spire.Doc.dll/Spire.XLS.dll. It's required to reference Spire.License.dll in your project if you use the class Spire.License.LicenseProvider in your code.
