none
Compiling with MSVC 2015 causes ERROR_DLL_INIT_FAILED when loading many DLLs even with /MD

    Question

  • I need to create potentially hundreds of DLLs and in extreme cases the host app will actually load all of them. These are tiny and all connect to one major DLL that implements the actual features. There's no other way around it, it's a world of plugins.

    Now when compiled and linked with MSVC 2013, it was all fine and I was actually able to load all of them at the same time. But I tried to switch to MSVC 2015 and when reaching say 60 plugins, LoadLibrary returns ERROR_DLL_INIT_FAILED.

    I googled it and it looked like the TLS table could be filled with C++ libs stuff, maybe something was added to MSVC 2015 I thought, so I tried compiling with /MD, no luck. Still does that (though the interface DLLs are much smaller).

    Any ideas?

    Sunday, March 06, 2016 3:51 PM

All replies

  • Hi Vojtech meluzin,

    Thanks for your post.

    >>Now when compiled and linked with MSVC 2013, it was all fine and I was actually able to load all of them at the same time.But I tried to switch to MSVC 2015 and when reaching say 60 plugins, LoadLibrary returns ERROR_DLL_INIT_FAILED.

    Did your project created in VS2013?

    To exclude the cause of your VS2015. Please create a new project like C++ console application. Then using MSVC2015 to compile it. Check whether it has the same error.

    Since the error was returned when reaching the 60th plugins. And it works well in VS2013. I suppose something was changed in MSVC 2015 which cause it's not compatible with the 60th plugin.

    In addition, since our forum is discussing about VS general question like how to set/configure Visual Studio and Visual Studio tools.

    And if we are sure the problem is not in your IDE. And for the compiling error. I suggest you could provide the detailed code or post it to the C++ forum for better support.

    Thanks for your understanding.


    Best Regards,

    Lake Xiao

    Monday, March 07, 2016 7:39 AM
    Moderator
  • Hi Lake,

    thank you for the reply. It's probably too late to start another thread somewhere else. Anyway I'm 100% sure it is VC2015. I'm usng commandline directly and tried several configurations etc. When compiled with VC2013, it is fine whether I use /MD or /MT. But I was wrong in the tests before - with VC2015, it does work ONLY if I use /MD. So apparently it started to using the TLS or something... Anyways I reverted to VC2013, easier solution.

    Monday, March 07, 2016 9:13 AM
  • Hi Vojtech meluzin,

    Thanks for your update.

    I don't encounter the same issue before. But I will did a research for your problem. Once have any update. I will post it here.

    Thanks for your understanding.

    Best Regards,

    Lake Xiao

    Tuesday, March 08, 2016 1:22 AM
    Moderator