License Issue with TeeChart in Unmanaged Windows Service

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
imdsoft
Newbie
Newbie
Posts: 8
Joined: Thu Apr 16, 2015 12:00 am

License Issue with TeeChart in Unmanaged Windows Service

Post by imdsoft » Sun Mar 31, 2024 2:12 pm

We are encountering a problem with TeeChart in our server application, specifically related to passing the license.
In our client application, we successfully add the license file as an embedded resource within the client EXE.
However, due to the server application being an unmanaged Windows service, we cannot follow the same approach.

Additional Information:
1. TeeChart.NET Version: We are using TeeChart.NET 4.2022.7.14.
2. Development Environment: Our service is developed using Visual Studio 2019 with unmanaged C++. The main logic of the application, including interaction with the TeeChart software, is written in C# targeting .NET 4.7.2.
3. Issue Manifestation: The result graphs display an evaluation banner that states, “This is an EVALUATION version of TeeChart.”

How can we address this issue without storing the license as a separate file on the server? Any guidance or recommendations would be greatly appreciated.

Thank you for your assistance!

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: License Issue with TeeChart in Unmanaged Windows Service

Post by Marc » Tue Apr 02, 2024 11:02 am

Hello,

Thank you for the information. We'll need to reproduce the setup as near as possible to test the problem and will likely need to ask you for more details.

To start with:
- how does the unmanaged C++ service call/load the C# app running TeeChart?
- Is it correct that the C# app itself is managed?

Regards,
Marc Meumann
Steema Support

imdsoft
Newbie
Newbie
Posts: 8
Joined: Thu Apr 16, 2015 12:00 am

Re: License Issue with TeeChart in Unmanaged Windows Service

Post by imdsoft » Sun Apr 07, 2024 3:29 pm

Hi Mark,

Thank you very much for your response.

Yes, you are correct. The service is unmanaged C++ and it loads and calls the C# app running TeeChart. It is also correct that the C# app itself is managed. The unmanaged service loads/calls the managed application using the COM interface. However, this is not necessary for you to use the COM model to reproduce (and hopefully to fix) the issue.

To make the reproduction easier I created a demonstrator that is simpler both to replicate and to debug.
You will need the following:
1. C# library running TeeChart with a single class and with TeeChart.dll as a reference. The only class:

Code: Select all

using System;

namespace LicenceTestLib
{
    public static class TeeChartTest
    {
        public static int Test(string _)
        {
            Console.WriteLine($"Entry assembly: {System.Reflection.Assembly.GetEntryAssembly()?.FullName ?? "<NULL>"}");
            var chart = new Steema.TeeChart.TChart();
            var path = System.IO.Path.GetFullPath("test.png");
            chart.Export.Image.PNG.Save(path);
            Console.WriteLine($"'{path}' file is generated.");
            return 0;
        }
    }
}
2. C++ console application, with the following code:

Code: Select all

#include <metahost.h>
#include <iostream>
#pragma comment(lib, "mscoree.lib")

int main()
{
    std::cout << "Started.\n";

    ICLRMetaHost* metaHost = NULL;
    ICLRRuntimeInfo* runtimeInfo = NULL;
    ICLRRuntimeHost* runtimeHost = NULL;

    if (CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost, (LPVOID*)&metaHost) == S_OK)
        if (metaHost->GetRuntime(L"v4.0.30319", IID_ICLRRuntimeInfo, (LPVOID*)&runtimeInfo) == S_OK)
            if (runtimeInfo->GetInterface(CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (LPVOID*)&runtimeHost) == S_OK)
                if (runtimeHost->Start() == S_OK)
                {
                    std::cout << "Runtime host is initialized\n";
                    DWORD pReturnValue;
                    runtimeHost->ExecuteInDefaultAppDomain(
                        L"LicenceTestLib.dll",
                        L"LicenceTestLib.TeeChartTest", L"Test", L"Arguments", &pReturnValue);
                    std::cout << "Execution completed. Result: " << pReturnValue << "\n";

                    runtimeInfo->Release();
                    metaHost->Release();
                    runtimeHost->Release();
                }

    return 0;
}
3. You can place the unmanaged console (EXE), managed DLL, and TeeChart.dll in the same folder and run the console.

I hope this will help you to advance with our issue.
Thank you in advance for your next reply.

Best regards,
Grigory Krylov
(Software Developer)

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: License Issue with TeeChart in Unmanaged Windows Service

Post by Marc » Mon Apr 08, 2024 1:44 pm

Hello Grigory,

Thank you for the example code. I can reproduce the issue using it. We're now looking at the cause.

Regards,
Marc
Steema Support

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: License Issue with TeeChart in Unmanaged Windows Service

Post by Marc » Mon Apr 08, 2024 3:15 pm

Hello Grigory,

Please test, adding: "[assembly: EntryAssembly]" to the C# project's AssemblyInfo file.
ie.

Code: Select all

using Steema.TeeChart;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("LicenceTestLib")]
[assembly: AssemblyDescription("")]
[assembly: EntryAssembly]
The license config is similar to that shown for ASP.NET here:
https://www.steema.com/docs/teechart/in ... #licensing

See section: "In ASP.NET project"

That tests ok here with your example, I hope it resolves the issue in your other project.

Regards,
Marc
Steema Support

imdsoft
Newbie
Newbie
Posts: 8
Joined: Thu Apr 16, 2015 12:00 am

Re: License Issue with TeeChart in Unmanaged Windows Service

Post by imdsoft » Tue Apr 09, 2024 12:47 pm

Hello Mark,

this works very well. Thank you very much for your help!

Regards,
Grigory

Post Reply