Loading and unloading the SDK DLLs dynamically hangs while executing loadToolbox() or unloadToolbox() within DllMain
This article is relevant for all .Net products
Some operations are risky to be called within a DllMain, like synchronization with other threads, this can cause deadlocks (see msdn.microsoft.com/en-us/library/windows/desktop/dn633971%28v=vs.85%29.aspx. The SDK does this kind of synchronization which causes such a deadlock.
To fix the problem, set up and tear down the SDK after loading and before unloading the DLLs via functions or static methods.