File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
src/MongoDB.Bson/Serialization Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,7 @@ public class BsonClassMap
38
38
private readonly static Queue < Type > __knownTypesQueue = new Queue < Type > ( ) ;
39
39
40
40
private static readonly MethodInfo __getUninitializedObjectMethodInfo =
41
- typeof ( string )
42
- . GetTypeInfo ( )
43
- . Assembly
44
- . GetType ( "System.Runtime.Serialization.FormatterServices" )
41
+ GetFormatterServicesType ( )
45
42
. GetTypeInfo ( )
46
43
? . GetMethod ( "GetUninitializedObject" , BindingFlags . NonPublic | BindingFlags . Public | BindingFlags . Static ) ;
47
44
@@ -1306,7 +1303,21 @@ private void ThrowNotFrozenException()
1306
1303
var message = string . Format ( "Class map for {0} has been not been frozen yet." , _classType . FullName ) ;
1307
1304
throw new InvalidOperationException ( message ) ;
1308
1305
}
1309
- }
1306
+
1307
+ private static Type GetFormatterServicesType ( )
1308
+ {
1309
+ #if NET452
1310
+ return typeof ( string )
1311
+ . GetTypeInfo ( )
1312
+ . Assembly
1313
+ . GetType ( "System.Runtime.Serialization.FormatterServices" ) ;
1314
+ #else
1315
+ return
1316
+ Assembly . Load ( new AssemblyName ( "System.Runtime.Serialization.Formatters" ) )
1317
+ . GetType ( "System.Runtime.Serialization.FormatterServices" ) ;
1318
+ #endif
1319
+ }
1320
+ }
1310
1321
1311
1322
/// <summary>
1312
1323
/// Represents a mapping between a class and a BSON document.
You can’t perform that action at this time.
0 commit comments