From discuss.elastic.co.
We don't really have that much running in .cctor. First thing I can think of is that here RuntimeInformation.FrameworkDescription.StartsWith causes the issue, although that seems to be strange.
One option could be to try-catch the platform detection here and report "unknown" if it fails.
But I'd prefer to understand why it fails in that particular environment and find some fix for it, instead of workarounding with a try-catch.
Hi! I just got the exact same error message but when I tried to break on exception I found out that the real error was that I had <dependentAssembly>
<assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly> in web.config which gave me a FileNotFoundException for InteropServices in PlatformDetection. But removing it solved the problem.
Hi! I just got the exact same error message but when I tried to break on exception I found out that the real error was that I had
<dependentAssembly> <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly>in web.config which gave me a FileNotFoundException for InteropServices in PlatformDetection. But removing it solved the problem.
Thanks for the info @Towmeykaw,
that sounds very reasonable. We have static properties in PlatformDetection.cs, like here and those are initialized in the .cctor (that's where the exception happens) and those properties are indeed initialized by using System.Runtime.InteropServices.RuntimeInformation. So very likely that a wrong version or a missing System.Runtime.InteropServices.RuntimeInformation can cause this.
There is already a try-catch merged to master, so even if this happens, we won't crash once that's release.
Again, thanks for the nice summery about the fix.
Closing now - the PR will prevent future crashes.
Most helpful comment
Thanks for the info @Towmeykaw,
that sounds very reasonable. We have static properties in
PlatformDetection.cs, like here and those are initialized in the.cctor(that's where the exception happens) and those properties are indeed initialized by usingSystem.Runtime.InteropServices.RuntimeInformation. So very likely that a wrong version or a missingSystem.Runtime.InteropServices.RuntimeInformationcan cause this.There is already a try-catch merged to master, so even if this happens, we won't crash once that's release.
Again, thanks for the nice summery about the fix.