Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2595

BsonClassMap type initializer throws exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.8.0
    • Fix Version/s: 2.8.1
    • Component/s: Serialization
    • Labels:
      None
    • Environment:
      dotnet core 3.0 preview4

      Description

      The exception is thrown at: https://github.com/mongodb/mongo-csharp-driver/blob/660658d4253f06506c1d60aae7ef68745ab609b2/src/MongoDB.Bson/Serialization/BsonClassMap.cs#L40

       

      It used to work up to and including dotnet core 3.0 preview3.

       

      Today I upgraded to preview4, causing this breaking change.

      I researched the issue briefly, apparently the new core version does not include the System.Runtime.Serialization.Formatters reference in CoreLib (so the System.Runtime.Serialization.FormatterServices type cannot be loaded this way).

       

      Assembly.Load("System.Runtime.Serialization.Formatters") will work instead of  typeof(string).GetTypeInfo().Assembly as a method to load the assembly, but it will not work with .net framework (so there is some versioning code required probably).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rstam Robert Stam
              Reporter:
              mcduck Konstantinos Sambanis
              Participants:
              Votes:
              5 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: