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
3838 private readonly static Queue < Type > __knownTypesQueue = new Queue < Type > ( ) ;
3939
4040 private static readonly MethodInfo __getUninitializedObjectMethodInfo =
41- typeof ( string )
42- . GetTypeInfo ( )
43- . Assembly
44- . GetType ( "System.Runtime.Serialization.FormatterServices" )
41+ GetFormatterServicesType ( )
4542 . GetTypeInfo ( )
4643 ? . GetMethod ( "GetUninitializedObject" , BindingFlags . NonPublic | BindingFlags . Public | BindingFlags . Static ) ;
4744
@@ -1306,7 +1303,21 @@ private void ThrowNotFrozenException()
13061303 var message = string . Format ( "Class map for {0} has been not been frozen yet." , _classType . FullName ) ;
13071304 throw new InvalidOperationException ( message ) ;
13081305 }
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+ }
13101321
13111322 /// <summary>
13121323 /// Represents a mapping between a class and a BSON document.
You can’t perform that action at this time.
0 commit comments