How to load the OPC UA Toolkit libraries dynamically
This article is relevant for all .Net products
Normally when loading a DLL library dynamically, the whole initialization is done during a DllMain function. None the less, some operations are very 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 loadToolbox() function does this kind of synchronization which would likely cause such a deadlock.
To fix the problem, call loadToolbox() or unloadToolbox() after loading the DLLs, respectively before unloading the DLLs. This can be done via functions or static methods. Also keep in mind, that all instances of SDK classes (including data classes) are destroyed before unloadToolbox() is called.