Page 1 of 1
License Issue with TeeChart in Unmanaged Windows Service
Posted: Sun Mar 31, 2024 2:12 pm
by 15673510
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!
Re: License Issue with TeeChart in Unmanaged Windows Service
Posted: Tue Apr 02, 2024 11:02 am
by Marc
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
Re: License Issue with TeeChart in Unmanaged Windows Service
Posted: Sun Apr 07, 2024 3:29 pm
by 15673510
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)
Re: License Issue with TeeChart in Unmanaged Windows Service
Posted: Mon Apr 08, 2024 1:44 pm
by Marc
Hello Grigory,
Thank you for the example code. I can reproduce the issue using it. We're now looking at the cause.
Regards,
Marc
Re: License Issue with TeeChart in Unmanaged Windows Service
Posted: Mon Apr 08, 2024 3:15 pm
by Marc
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
Re: License Issue with TeeChart in Unmanaged Windows Service
Posted: Tue Apr 09, 2024 12:47 pm
by 15673510
Hello Mark,
this works very well. Thank you very much for your help!
Regards,
Grigory