Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 0b6e613

Browse files
committed
Add fallback to check Env Var if appSettings verification failed
1 parent 76792c2 commit 0b6e613

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/ServiceStack.Text/PclExport.Net40.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,30 @@ public override void RegisterLicenseFromConfig()
130130
#elif __IOS__
131131
#elif __MAC__
132132
#else
133-
//Automatically register license key stored in <appSettings/>
134-
var licenceKeyText = System.Configuration.ConfigurationManager.AppSettings[AppSettingsKey];
135-
if (!string.IsNullOrEmpty(licenceKeyText))
133+
string licenceKeyText;
134+
try
136135
{
137-
LicenseUtils.RegisterLicense(licenceKeyText);
138-
return;
136+
//Automatically register license key stored in <appSettings/>
137+
licenceKeyText = System.Configuration.ConfigurationManager.AppSettings[AppSettingsKey];
138+
if (!string.IsNullOrEmpty(licenceKeyText))
139+
{
140+
LicenseUtils.RegisterLicense(licenceKeyText);
141+
return;
142+
}
143+
}
144+
catch (Exception ex)
145+
{
146+
licenceKeyText = Environment.GetEnvironmentVariable(EnvironmentKey)?.Trim();
147+
if (string.IsNullOrEmpty(licenceKeyText))
148+
throw;
149+
try
150+
{
151+
LicenseUtils.RegisterLicense(licenceKeyText);
152+
}
153+
catch
154+
{
155+
throw ex;
156+
}
139157
}
140158

141159
//or SERVICESTACK_LICENSE Environment variable

0 commit comments

Comments
 (0)