File tree 1 file changed +16
-4
lines changed
src/Elasticsearch.Net/Connection/MetaData
1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -45,12 +45,24 @@ internal sealed class RuntimeVersionInfo : VersionInfo
45
45
46
46
public RuntimeVersionInfo ( ) => StoreVersion ( GetRuntimeVersion ( ) ) ;
47
47
48
- private static string GetRuntimeVersion ( ) =>
48
+ private static string GetRuntimeVersion ( )
49
+ {
50
+ try
51
+ {
49
52
#if ! DOTNETCORE
50
- GetFullFrameworkRuntime ( ) ;
53
+ return GetFullFrameworkRuntime ( ) ;
51
54
#else
52
- GetNetCoreVersion ( ) ;
55
+ return GetNetCoreVersion ( ) ;
53
56
#endif
57
+ }
58
+ catch
59
+ {
60
+ // Swallow these to avoid crashing, just because we fail to detect the framework.
61
+ // Mostly affects Xamarin Forms.
62
+ }
63
+
64
+ return null ;
65
+ }
54
66
55
67
#if DOTNETCORE
56
68
private static string GetNetCoreVersion ( )
@@ -65,7 +77,7 @@ private static string GetNetCoreVersion()
65
77
return RuntimeInformation . FrameworkDescription . Substring ( dotNet . Length ) ;
66
78
}
67
79
}
68
-
80
+
69
81
// next, try using file version info
70
82
var systemPrivateCoreLib = FileVersionInfo . GetVersionInfo ( typeof ( object ) . Assembly . Location ) ;
71
83
if ( TryGetVersionFromProductInfo ( systemPrivateCoreLib . ProductVersion , systemPrivateCoreLib . ProductName , out var runtimeVersion ) )
You can’t perform that action at this time.
0 commit comments