I’ve bought a licence and it works fine locally, but when I deploy to a remote server and run it through IIS, I get the following exception:
ServiceStack.LicenseException: The free-quota limit on ‘10 ServiceStack Operations’ has been reached.
I’ve tried setting my licence key through:
Enviroment Variable
web.config
And hard-coding the licence key in the
code, without any success
This suggests that no license key was registered. If you added it as an Environment Variable on the remote computer you’ll need to restart IIS to pick up the changes. Otherwise hard coding the license key definitely works.
Otherwise double-check that the server generating the License Exception is definitely the server where you’re trying to register the License. If you continue to have issues please email team@servicestack.net with the License Key you’re using and we can verify if you’re using a valid License Key.
Ok it wont be returning All from the Server that’s throwing the License Exception. If the License Key was invalid it would’ve thrown an Invalid License Key error where as this License Exception suggests no License Key was registered at all. So my only suggestion is to double-check the server that’s throwing the Exception is definitely the Licensed Server where the License Key was registered on.
You can also try deploying to a clean virtual directory, i.e. clear out the entire directory where it’s deployed to, or just the /bin folder in-case you have some dirty .dll’s that’s causing the issue.
Another thing you can try is creating a Service that returns whether a License has been registered with:
[Route("/licensed")]
public class CheckLicense {}
public class MyServices : Service
{
public object Any(CheckLicense request) =>
(LicenseUtils.ActivatedLicenseFeatures() == LicenseFeature.All).ToString();
}
You’ll need to temporarily comment out your other Service classes so you can get below the 10 operation free quota limit so ServiceStack AppHost is initialized.
This is going to return “False” in a server that doesn’t have a license key registered but at least with the new Service you can verify deployments to your remote IIS Server are actually being done.
If it does return false, try registering the License Key in code and throwing a custom Exception immediately after, i.e:
protected void Application_Start(object sender, EventArgs e)
{
Licensing.RegisterLicense(@"replace with license key text");
if (LicenseUtils.ActivatedLicenseFeatures() != LicenseFeature.All)
throw new Exception("License Registration failed");
new AppHost().Init();
}
The Exception should never be thrown as registering a valid license key in code like this will always work.
My assumption is simply that the License Key isn’t being registered on the server that’s throwing the License Exception or there is an issue with deployments that’s preventing new deployments.
I’ve managed to sort it out through Environment Variables, when I restarted the IIS I did it with the GUI. But it seems you need to do it with commandline.
With regards to setting it in code, I had to do it in the Program -> Main function, anything later than that seem to give me an error.
I deleted my previous addition to this thread, but to anyone else stumbling in here because your xUnit / nunit tests fail:
If you are using some build system (TeamCity, Jenkins), add an environmental variable to be set when building. From what I can tell xUnit tests have no “Main” entry point, and calling RegisterLicenseKey in AppHost.Configure is too late - it will fail.