Open NoahStahl opened 9 years ago
Could you please post a complete stack trace of that exception?
Sure:
System.FormatException: String was not recognized as a valid DateTime because the day of week was incorrect.
Stack trace:
at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style)
at System.DateTime.ParseExact(String s, String format, IFormatProvider provider, DateTimeStyles style)
at Portable.Licensing.License.get_Expiration()
at Portable.Licensing.Validation.LicenseValidationExtensions.1..ctor(IEnumerable
1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
I'm having the same issue...
See related github issue here
<Expiration>Fri, 31 Dec 9999 23:59:59 GMT</Expiration>
This date blows up on just some of my customer's machines. I have not been able to repro on any environment. Below is a screenshot that one of them sent me.
.
Looks like when you have a license with a expiration date of DateTime.MaxValue which is (Fri, 31 Dec 9999 23:59:59 GMT), some version of visual studio/.net fail. I was unable to replicate this on vs 2012, 2013, 2015 but other user's of my project were.
My solution was to generate a permanent license that expires in a 100 years instead of using DateTime.MaxValue.
When testing modifying the expiration date in the license file, it appears that the DateTime parsing exceptions are not handled and translated into a proper IValidationResult. Instead, an exception is thrown as soon as the result is accessed. An example exception: "String was not recognized as a valid DateTime because the day of week was incorrect."
I'm working around this by surrounding my validation check in a try block, but it would be nice for invalid expiration dates to trigger the normal "License signature validation error" message.
Great work, thanks for this!