Use Spread9 in a WPF class assembly (DLL)

Posted by: jon-summers on 10 September 2017, 10:59 am EST

  • Posted 10 September 2017, 10:59 am EST

    When I create an EXE using Spread9 in a WPF app., all works fine.
    When I create a WPF DLL (class assembly) that attempts to use Spread9, I see two problems:
    1 The Viz Studio editor does not show Spread9 at design time
    2 At run-time I get an error telling me that a 'License for GcSpreadSheet cannot be found in the program.' See attached screenshot.

    Is it possible to build a DLL that provides a WPF UI that can display Spread9?
    Regards, Jon Summers

  • Replied 10 September 2017, 10:59 am EST

    Hello,

    I am not able to replicate this issue at my end.
    1. Visual Studio will require the Spread dlls to be present with the user control and also the machine should have a valid license. Then you can work with user control created with Spread at design time.
    2. The reason is stated that you need to include the Licenses.licx file in your project when creating the user control. In case you have a licenses.licx file added already , please make sure that the version number mentioned for Spread in it same as shown by the dll in references.


    I tested this issue at my by creating a user control and using this user control both in licensed and unlicensed machine.
    a. On unlicensed machine it shows the license error design time(but not the licenses.licx error) and works fine at run time.
    b. On licensed machine the user control works fine both at run time and design time.

    Please refer to the attached images.

    Hope it helps.

    P.S. You can add the run time license by running the license activation tool from "Tools" menu in Visual Studio.
    Regards,
    Deepak Sharma





  • Replied 10 September 2017, 10:59 am EST

    @DeepakSharma14 said:I am not able to replicate this issue at my end

    Thanks, but you've answered a different question to the one I asked. As I wrote, if I create an executable Windows app with a WPF interface then I can successfully add and use Spread9 WPF with no problem. It obtains a license at design time and at run time.

    My problem arises when I create a class assembly (i.e. a DLL not an EXE) and that DLL has a user interface. I want to place a Spread9 WPF in a WPF container that is part of my DLL. I'm not talking about the GrapeCity DLLs, that are Viz Studio references. At design time I don't see Spread9 — even though the license file is present.

    At run-time the DLL is hosted by an EXE that has no user interface. That is, at run-time the interface for the host EXE is provided by the WPF DLL. It's at run-time the 'no license' message appears.

    The problem I describe is specific to Spread9 WPF. I have not had this problem in the past with Spread8 COM, and I don't have this problem now with Spread9 in WinForms.
  • Replied 10 September 2017, 10:59 am EST

    Hi,

    Sorry for inconvenience.
    Please upload your application to some upload website and provide me the link to download the same.


    Thanks,
    Deepak Sharma


  • Replied 10 September 2017, 10:59 am EST

    Here's the example WPF solution:
    http://www.la-solutions.co.uk/downloads/DllUsingSpread9.zip
    It contains two projects: a client (*.exe) and a server (*.dll). The server is a .NET class assembly and implements the WPF user interface.
    At run-time Spread9 does not obtain a license.
  • Replied 10 September 2017, 10:59 am EST

    Hello,

    You need the Licenses.licx file to be added to your Client project as well. I have modified your sample application and attached it back for your reference. I have also attached an image showing your application working fine at my end with Spread 9.0.

    Thanks,
    Deepak Sharma


    2017/07/DllUsingSpread9.zip
  • Replied 10 September 2017, 10:59 am EST

    @DeepakSharma14 said:You need the Licenses.licx file to be added to your Client project as well.


    That's possible when you are in control of the client project. However, the intended use of the DLL hosting Spread9 is to run in the address space of a third-party host. I have no control over that third-party EXE, and hence cannot add your license to it.

    Let me repeat that I have had no problem using Spread8 COM in that scenario, nor is there a problem using Spread9 for WinForms in that scenario. It's only Spread9 WPF that has this issue. Why can't Spread9 look in the DLL assembly to get its license?
  • Replied 10 September 2017, 10:59 am EST

    Hello,

    Spread 8 COM and Spread 9 for WPF are absolutely different controls.
    I tested this issue by creating a UserControl Library with Spread for WPF which is a DLL. After creating this DLL I tried to use it in a new project and I was able to add it with no issues. As shown in the image I attached with my previous response.
    Could you please provide me your sample application to test?


    Thanks,
    Deepak Sharma
  • Replied 10 September 2017, 10:59 am EST

    @DeepakSharma14 said:
    Could you please provide me your sample application to test?

    See attached ZIP containing DllSpread9 Viz Studio solution.
    The Client project is a simple executable that attempts to open a WPF Window in the DllSpread9 class assembly (DLL).
    The attempt fails because it can't obtain a license.
    Your site won't let me upload an example file (2MByte size). Can I e-mail it?
  • Replied 10 September 2017, 10:59 am EST

    Here's another attempt at a file upload, but it failed again. Why can't I upload this file? It's size is 2095Kbyte -- your site says the maximum size is 3000Kbyte.
  • Marked as Answer

    Replied 10 September 2017, 10:59 am EST

    Hello,

    I understand the scenario. However when I checked this issue with the latest version of Spread i.e. v10.0 I could not replicate the same. It works with the licenses.licx file for the Client project when I used Spread 10 for WPF in your project.

    I would suggest you to please download the latest version and test this issue with the same.

    Thanks,
    Deepak Sharma
Need extra support?

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

Learn More

Forum Channels