Matlab issue when using external activation

I am using Win10, Matlab 2021a.
I activate my license using an external tool which works fine.

Then I want to check the license status using Matlab. However, the function

status = calllib('LexActivator','IsLicenseGenuine');

returns ‘1’, which means the license check failed. Only after I run

 status = calllib('LexActivator','SetLicenseKey', toString(sLicenseKey));
 status = calllib('LexActivator','ActivateLicense');

the check

status = calllib('LexActivator','IsLicenseGenuine');

returns the correct value. So it seems as if the external activation does not have an effect for Matlab.

How can I debug this?

Are you passing LA_USER in both the SetProductId functions of both the tools. Because activation data is stored per user.

thanks for the fast reply.
For the activation I use a node program and the LA_USER is PermissionFlags.LA_USER
In matlab i use uint32(1) for the user. so it should be the same, shouldn’t it?

Do you face the same issue when you

1- Activate the license with tool B

2- Restart Tool B

3- Verify the license on tool B

Not exactly. When I use Tool B (Matlab), and activate the license, it will always show “license genuinely activated”, even if I suspend it.
When I try to activate a suspended license again (which does not make sense but anyway), I get the error: License activation failed: 53
When I then check the license, the license check fails with status 1

Only reason it can happen (one tool not detecting the activation of other) is if the two apps are being run using different user accounts. Can you try using the latest version of LexActivator (in case you are using any old version).

I downloaded the latest binarys (dll) to use it with Matlab. So it should be up-to-date…

Can you replicate the issue using the C++ sample, for example compiling them as two different tools and following your steps?

I didn’t have the time to replicate the issue. But it seems the problem does not appear if I call calllib('LexActivator','ActivateLicense'); (even without setting the actual LicenseKey) every time before I call calllib('LexActivator','IsLicenseGenuine');. However, it feels strange to do that. But it is the only way it works. Could you comment on that?

When you call SetLicenseKey() function on any machine, the key is persisted on disk. Hence your code is working. You should call ActivateLicense only when IsLicenseGenuine returns 1.