Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

MongoDB and Unity IL2CPP mobile builds

I’m having problems getting MongoClient() in Unity, here is the code:

        private const string MONGO_URI = "mongodb+srv://user:password@testing-obdcf.mongodb.net/test?retryWrites=true&w=majority";

        private IMongoClient client;
        private IMongoDatabase db;


        void Start()
        {
            Debug.Log("TEST REACHED START");
            client = new MongoClient(MONGO_URI);;
            Debug.Log("TEST MDB CLIENT" + client);

        }

Everything works fine in the Unity editor, the problem is when building to mobile in IL2CPP.

XCode debug:

TEST REACHED START

NotSupportedException: ./External/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System.Reflection/Module.cpp(112) : Unsupported internal call for IL2CPP:Module::GetPEKind - “This icall is not supported by il2cpp.”

(Filename: currently not available on il2cpp Line: -1)

Unity Android Debug:

AndroidPlayer(ADB@127.0.0.1:34999) NotSupportedException: /Applications/Unity/Hub/Editor/2019.3.3f1/Unity.app/Contents/il2cpp/libil2cpp/icalls/mscorlib/System.Reflection/Module.cpp(112) : Unsupported internal call for IL2CPP:Module::GetPEKind - “This icall is not supported by il2cpp.”

Found a thread in stack overflow from 7 months ago that says the following:

  • MongoDB C# Driver is currently (as of Unity 2019.1.13f1) not compatible with IL2CPP on Hololens because it tries to make an icall not supported by the latter (very specifically when trying to call new MongoClient()).

I got the DLLs from this repo, maybe they are not updated and mongoDB fixed this issue, i’d really appreciate some help in this, thanks!

I am having the same problem, did you solve it?