VS2022 Unit Test

Posted by: rudi.sugiato on 10 November 2022, 6:59 am EST

    • Post Options:
    • Link

    Posted 10 November 2022, 6:59 am EST

    We have some unit test execution / test scenarios that calls ActiveReports components. We are able to properly license these code for normal operation when used in Web Applications but when the same code is called by the test runner, they fail with the same error as if it’s not properly licensed.

    This application will be terminated because it was built without a license for SectionReport.

    I am not entirely sure what the calling application is when VS2022 run the unit test but if I believe that may be the culprit of not properly generating gclicx for when it’s called during test executions.

  • Posted 10 November 2022, 9:39 pm EST

    Hi Rudi,

    The calling application is the “class library” which directly references ActiveReports components. And the executing application is the root level or main application that is getting executed.

    For example, if I have a class library with the assembly name “Exports” which uses ActiveReports export references, and the my application has an assembly name “TestApp” which calls my “Exports” library. The command for creating .gclicx file would look like

    C:\ProgramData\GrapeCity\gclm>gclm.exe "5e0b5f44-1a6b-4aff-a007-17b9224bca83" -lc ./license.gclicx "TestApp.Exports.dll"

    Also, Please note: If you are using ‘.gclicx’ file to license your application you may delete the ‘licenses.licx’ file from your project as this file can throw such exceptions when run on a system with no ActiveReports license. You can find this file under Solution Explorer > Properties.

    To learn more about licensing compiled code please refer to https://www.grapecity.com/activereportsnet/docs/latest/online/licensing-compiled-code.html.



  • Posted 11 November 2022, 1:16 am EST

    Hi Anand, thanks for the reply. The method you’re suggesting is what we’ve already used to resolve license issues in most part of the applications. However, for this same application which has unit test, this particular area is not working. Partly because I dont know the ‘calling’ application when unit test is run. This may be general question about how visual studio works behind the scene when executing unit tests. I’ve tried adding the following pairing but none works:

    • devenv
    • xunit.console
    • vstest.console

      And i’ve looked and confirm that there is no licenses.licx in the solution.
  • Posted 14 November 2022, 2:36 pm EST

    Hi Rudi,

    The calling assembly will always remain the same for a class library i.e. the Assembly that calls the ActiveReports references is only going to be the calling assembly. However, in your test environment, the Executing Assembly will change which will be equal to the Assembly name in which your tests are executed.

    To check the assembly name of the project that contains your test cases please open the project in VisualStudio > right-click on your Project > Click on Properties > Go to Application Tab, there you’ll find the Assembly Name which is going to be the Executing Assembly when you run your test cases.

    You may also use the following methods to get the names of the Calling/Executing Assemblies:


    Also, please note: You’ll require ActiveReports License on any system in which you Build/Rebuild your project that calls ActiveReports references.



  • Posted 15 November 2022, 1:00 am EST

    Thanks Anand, i will give it a try.

    The one thing that seems to work is to add an Active Report item to the offending project/assembly and then find the dll.licenses file from the obj folder and then add it as embedded resource. This allows us to get pass the licensing error. Any potential issue we’re not seeing with this approach?

  • Posted 15 November 2022, 9:48 pm EST

    Hi Rudi,

    It looks like you are using an older version of ActiveReports which uses licenses.dll file to license a class library, it is a correct way to license a class library for legacy ActiveReports.

    To learn more about using the licenses.dll file to license your project you may refer to this documentation of ActiveReports 7:


    Under ActiveReports Developer 7 > License Your ActiveReports > ‘To license a class library project’.

    Or visit ActiveReports Legacy Documentation page to find out the steps required to license a class library for your version of ActiveReports:




  • Posted 16 November 2022, 12:35 am EST

    That’s strange, the reason we’re having this issue is because we’re trying to upgrade from version 9 to version 16.1. We updated all references from 9 to 16 and the workaround I explained with the licenses.dll is what seems to make this work.

    I can double check again but all references are now using 16.1.

  • Posted 16 November 2022, 8:02 pm EST - Updated 15 February 2023, 1:41 am EST

    Hi Rudi,

    Could you confirm if you are referring to ActiveReports 9 ‘licenses.dll’ in your ActiveReports 16 project? If yes this is an incorrect way of licensing your class library as the licensing methods have changed from ActiveReports 9 to ActiveReports 16.

    In ActiveReports 16 you do not need to manually refer to any ‘licenses.dll’ file.

    In order to license your Class Library please follow the below-given steps:

    • Remove any reference for ActiveReports 9 licensing DLLs.
    • Open the Command line and change the working directory to C:\ProgramData\GrapeCity\gclm using the command
    cd C:\ProgramData\GrapeCity\gclm
    • Specify a location to store your .gclicx file and run the following command to create a ‘.gclicx’ file.
    gclm.exe "e88c1aa3-2781-44bb-b639-765c9ef6d15c" -lc [location_to_save_the_gclicx_file]/license.gclicx "[ExecutingAssembly].[CallingAssembly].dll"
    • Copy the ‘license.gclicx’ file and paste it into any folder in your ‘MyReportAR’ project’s directory.
    • Open your ‘MyReportAR’ project in VisualStudio locate the ‘license.gclicx’ file through Solution Explorer > right-click the ‘license.gclicx’ file > click on Properties.
    • Set the Build Action property to Embedded Resource.
    • Rebuild your class library.

    Now running your MyReportService application should not throw any error.

    Please make sure to set the ‘.gclicx’ file’s Build Action to Embedded Resource failure to do so will result in the similar error.

    To learn more about licensing compiled code in ActiveReports 16 please refer to Licensing Compiled Code [https://www.grapecity.com/activereportsnet/docs/versions/v16/online/licensing-a-project.html].

    To learn more about Licensing your project please refer to Licensing a Project [https://www.grapecity.com/activereportsnet/docs/versions/v16/online/licensing-a-project.html].

    To read more about common licensing error and how to fix them please refer to Licensing Errors [https://www.grapecity.com/activereportsnet/docs/versions/v16/online/licensing-errors.html].

    Please find attached a sample implementing a ‘MyReportAR’ class library with ‘license.gclicx’ file embedded to the project. And ‘MyReportService’ application using MyReportAR.dll.

    • To Run the project open the project in Visual Studio.
    • Right click on ‘MyReportAR’ project and click on Build to create MyReportAR.dll.
    • Run the ‘MyReportService’ application. Everything should run as expected.
    • Now if we change the ‘license.gclicx’ file’s (within ‘MyReportAR’ project) Build Action to None and Build the project again.
    • Running the ‘MyReportService’ app will throw the error ‘This application will be terminated because it was built without a license for PageReport.’.




  • Posted 17 November 2022, 2:12 am EST - Updated 17 November 2022, 2:19 am EST

    Thank you for the sample project and explanation. I will open it up and give it a try. I failed to mention that the reason why our workaround works with the licenses.dll is because I had to combined it with the instruction you provided in regards to creating and embedding the gclicx file. We follow that instruction very closely and it was still complaining about license. Only when we also add the dll.licenses into the top level main application, the license error is gone.

    For example, we’ve tried adding gclicx to the libraries that references AR and embed it as resource. I looked at the resulting compiled dll with DotPeek and can confirm that there are gclicx embedded.

    When the libraries are called by our ASP Webform website (for example Tracker.Web.dll) the license error still shows up.

    I noticed there are subtle differences in Tracker.Web.dll when it’s not working (by following the licensing instruction) vs using workaround (which works) by also adding the dll.licenses (from obj folder of webform project) to the Tracker.Web as embedded resource.

    This subtle difference in Tracker.Web.dll is what I believe that makes it work, see the attached file licenses

    It works (no license error) if the top level calling application has the dll.licenses embedded. And it DOES NOT work when it doesn’t have it.

    I understand this is not what according to the documentation on how to license AR 16 but the exact steps on the documentation DOES NOT work for us, while this works.

    I don’t know the inner working how you enforce the license but perhaps you can explain what happened here and why this works?

  • Posted 17 November 2022, 9:40 pm EST

    Hi Rudi,

    >> I don’t know the inner working how you enforce the license but perhaps you can explain what happened here and why this works?

    The ‘…dll.licenses’ file shown in your attached file is generated when your project is successfully licensed using the respective license file (.gclicx or .licx) looking at your ‘dll.licenses’ file we could observe your application has been licensed using ActiveReports 16 GUID i.e. your “.gclicx” file worked as expected.

    However, it is still not clear if your application is correctly licensed then what could be the reason for it to throw the error when you include the ‘.gclicx’ file in your project.

    Please share a stripped-down sample, or a sample with the same app structure with respect to ActiveReports also having the same .NET versions and share it with us along with your “.gclicx” file so we could replicate the issue and further investigate the same.

    Thanks & Regards,


  • Posted 19 October 2023, 1:44 am EST - Updated 19 October 2023, 6:01 pm EST


    I have the same issue with my unit tests. I have used the sample you gave and complete it with a unit test project and I still figure out how to make my unit test pass.

    For information, I have migrated all projects into new csproj format, target framework into .net7.0 and migrate to Active Reports version 17.

    I received always the same error : “This application will be terminated because it was built without a license for PageReport.”

    I have tried to follow your guide but it does not work https://www.grapecity.com/activereportsnet/docs/latest/online/licensing-compiled-code.html

    I have tried to generate a .gclicx file with the following command line and add it into MyReportAR project as Embeded Resources but it does not work :

    gclm.exe "742a5cf8-2204-4873-9dc9-ff56d67411bd"  -lc .\license.gclicx "TestProject1.MyReportAR.dll"

    You can find my example in attached to this topic.


  • Posted 19 October 2023, 6:24 pm EST

    Hi Michael,

    For the Unit Test project the entry assembly name is ‘testhost’, please try generating a ‘.gclicx’ license file using the following command:

    C:\ProgramData\GrapeCity\gclm>gclm.exe "742a5cf8-2204-4873-9dc9-ff56d67411bd" -lc ./.gclicx "testhost.TestProject1.dll"

    After which embedding the generated ‘.gclicx’ license file into the TestProject1 project will run the Tests as expected.



  • Posted 19 October 2023, 6:55 pm EST

    It works ! Thank you for your help :slight_smile:

  • Posted 19 October 2023, 7:32 pm EST

    Glad to help!

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels