Setting an APOSE license in .NET (Web Projects)

Hi,

I’ve bought the Aspose.Pdf.Kit license. I’ve followed the instructions to add the .lic file as an embedded resource in a Visual Studio Project, an it works (as explained in Aspose PDF License|Aspose.PDF for .NET)

I need to to the same in another project of the same solution, which is a web project. When I add the file as an existing item and edit its properties, the “build action” property is not available, so how could I set the .lic file as an embedded resource in a web project of Visual Studio?

If I add that file to the web project without any further settings, I get the exception:

Exception Details:

System.IO.FileNotFoundException: Cannot find license 'Aspose.Pdf.Kit.License.lic'.

Also, I’ve added the license.SetLicense() code in the global.asax file, Application_Start() method, is that correct?

Hi,

Thank you for considering Aspose.Pdf.kit

It is only required to set a license once per application (or process). The instructions that you have followed were for Aspose.total component. Kindly visit the following link for Aspose.Pdf.Kit component license instrucitons.

http://www.aspose.com/documentation/file-format-components/aspose.pdf.kit-for-.net-and-java/licensing.html

The easiest way to set a license is to put the license file in the same folder as Aspose.Pdf.Kit.dll and specify just the file name without path as shown in the following example:

C#]

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense("Aspose.Pdf.lic");

Hi,

I use the library in two types of Visual Studio projects:

- Windows Application proejct
- ASP.NET Web Application project

For the first project type I can add the license file as explained in the link (thanks!). But still my question is where to include the code lines which instantiate the License object:

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense("Aspose.Pdf.lic");


For the second project type, I'd like to know how to add the license file because it differs. About the code lines which instantiate the License object in this project type, I've included them in global.asax -> Application_Start(), but I'm not able to test it yet until I add the .lic file properly.



Thanks.

1 Like

Hi,

If you use the following code to set license (assume your license is in the Resources folder under your web project):

string path = MapPath(".");
path = path.Substring(0, path.LastIndexOf("\\"));
path = path + "\\Resources\\Aspose.Pdf.lic";

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense("Aspose.Pdf.lic");

You can add those lines before you creating the first instance of Pdf object.