diff --git a/ImeSharp/TextServicesContext.cs b/ImeSharp/TextServicesContext.cs index f701edd..87e53b5 100644 --- a/ImeSharp/TextServicesContext.cs +++ b/ImeSharp/TextServicesContext.cs @@ -204,10 +204,17 @@ public ITfThreadMgrEx ThreadManager { if (_threadManager == null) { - ITfThreadMgr threadMgr; - Tsf.GetThreadMgr(out threadMgr); + ITfThreadMgr threadMgr = null; + try + { + // This might fail + Tsf.GetThreadMgr(out threadMgr); + } + catch (SharpGen.Runtime.SharpGenException) + { + } - // Dispose previous ITfThreadMgr in case something weird happens + // Dispose previous ITfThreadMgr in case something weird happens if (threadMgr != null) { if (threadMgr.IsThreadFocus)