Getting following error on startup, our license is valid till 2019. I added binding redirect for System.Runtime as well.
ServiceStack.LicenseException: This license is invalid. Please see servicestack.net or contact team@servicestack.net for more details. The id for this license is '6253' ---> System.BadImageFormatException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058) ---> System.BadImageFormatException: Cannot load a reference assembly for execution.
--- End of inner exception stack trace ---
at System.MemoryExtensions.AsSpan(String text)
at ServiceStack.Text.Jsv.JsvReader`1.Parse(String value)
at ServiceStack.Text.TypeSerializer.DeserializeFromString[T](String value)
at ServiceStack.LicenseUtils.ToLicenseKeyFallback(String licenseKeyText)
at ServiceStack.LicenseUtils.RegisterLicense(String licenseKeyText)
--- End of inner exception stack trace ---
at ServiceStack.LicenseUtils.RegisterLicense(String licenseKeyText)
The issue is not with the license key but with an invalid project configuration where it’s unable to load the System.Runtime dependency, if this is a .NET Core project can you try manually adding a reference to System.Runtime in your .csproj:
<Reference Include="System.Runtime"/>
Although the BadImageFormatException usually means an invalid bitness error, e.g. you’re trying to load 64-bit native dll into a 32-bit process.
Otherwise please upload a small project with the error on GitHub (don’t include your License Key) and send me a link to it and I’ll check it out.
I think I figured out the issue. SS is asking for .net core version of System.Runtime instead of .net framework. Is there a way to force add the reference to .net core version of the System.Rutime?
No, not using ASP.net core, my project is .net 4.5.7. Not sure why SS is looking for .net core references instead. It used to work just fine before v5.2.
No, it’s got nothing to do with ServiceStack’s classes dependencies. If anything it can be caused by invalid binding redirects, so you can try removing all binding redirects, uninstalling packages and try installing from a clean slate to see if that helps.
But unless you send me a repro I won’t be able to help any further.