TSF exception when my control loses focus with Japanese IME active

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
I am trying to add TSF (Text Service Framework) support to my text based custom control. It is mostly working, however a Value does not fall within the expected range. exception is periodically thrown when I call OnLockGranted on the ITextStoreACPSink
interface. This only happens when the Japanese IME is active. Chinese and Korean are working fine.
The easiest way for me to trigger the exception is to switch from English to Japanese, and then just make my control lose focus. Also, after typing in several characters the exception also happens. If I just ignore these exceptions it still seems to
work ok.
I use C#, so I have declared all of the relevant TFS COM interfaces in C# in my application.
From looking at the call stack it looks like this is a problem in the Managed to Native Transition. I have tried debugging this in WinDbg, but I cant seem to get any relevant information on why this is happening.
Here is the call stack:
[Managed to Native Transition] <br/>
> TFSSampleApp2.exe!TFSSampleApp2.RichTextStore.RequestLock(TSF.TS_LF dwLockFlags, out TSF.TextStoreReturnValues phrSession) Line 244 + 0xf bytes C#<br/>
[Native to Managed Transition] <br/>
[Managed to Native Transition] <br/>
System.Windows.Forms.dll!System.Windows.Forms.Control.FocusInternal() + 0xa2 bytes <br/>
System.Windows.Forms.dll!System.Windows.Forms.TextBox.WndProc(ref System.Windows.Forms.Message m) + 0x59 bytes <br/>
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0x10 bytes <br/>
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x31 bytes <br/>
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) + 0x57 bytes <br/>
[Native to Managed Transition] <br/>
[Managed to Native Transition] <br/>
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason, int pvLoopData) + 0x24e bytes <br/>
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) + 0x177 bytes <br/>
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes <br/>
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x31 bytes <br/>
TFSSampleApp2.exe!TFSSampleApp2.Program.Main() Line 19 C#<br/>
[Native to Managed Transition] <br/>
[Managed to Native Transition] <br/>
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x3a bytes <br/>
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2b bytes <br/>
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x66 bytes <br/>
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes <br/>
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
Thanks,
Peter

View the full article
 
Back
Top