How to embed or use the license file (.lic) for Aspose.Cells in an SSIS package?

How to embed or use the license file (.lic) for Aspose.Cells in an SSIS package? Currently when I generate an Excel file using Aspose.Cells, it adds a sheet with the information Evaluation Copy. I have the license file but I am not sure how to add it to my SSIS package? I go in circles on the internet trying to find a suitable method to do that. Any help in the right direction is appreciated. Thanks!

I added the below functions/constructors to my SCRIPT class in the SSIS package.
The static constructor loads the DLL at runtime so I didn’t have to register it in the GAC. I am adding this code to every SCRIPT task where I use Aspose.Cells.

NOTE - The Aspose.Cells DLL and the LIC files are stored in C:\Aspose\ folder. The license needs to be loaded only once in the package - in the first SCRIPT task where Aspose.Cells is used; you don’t need to add the SetLicense function to every SCRIPT task where Aspose is being used.

    static ScriptMain()
    {
        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
        SetLicense(); 
    }

    static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
        if (args.Name.Contains("Aspose.Cells"))
        {
            string path = @"C:\Aspose\"; 
            return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Aspose.Cells.dll"));
        }
        return null;
    }

    static void SetLicense() {
        License lic = new License();
        lic.SetLicense("C:\\Aspose\\Aspose.Cells.LIC");
    }

@premakumari,

Thanks for the sample code segment and details.

It looks like you have sorted out your issue now. And, yes, you do not require to instantiate/set license several times as it only needs to be instantiated/set once. See the document on Licensing for your further reference:

I’m having trouble getting this to work in a Visual Studio 2012 C# Script Task. I’ve successfully added the code above to register Aspose.Cells.dll as well as set the license, but the SSIS package crashes when it hits this line:

        Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();

DTS is reporting the “Exception has been thrown by the target of an invocation.” error message.

Do you have any suggestions on how to fix this?

Thank you!

Disregard my question, I figured out that my code cannot be in the Main() function, I just had to move it to a separate function and call that function from Main()

@softwarelicense_aixgroup_com,

Good to know that your issue is sorted out. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.