Closed point32 closed 5 months ago
protected override void LoadContent()
{
var form = (Form)Window.GetType().GetField("Form", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(Window)!;
InputMethod.Initialize(form.Handle, tsfForceDisabled: true);
}
当我把LoadContent
中的Initialize
调用增加上tsfForceDisabled
参数并设置为true时,上述代码正常运行,且不再抛出该异常
项目模板:MonoGame Windows Desktop Application(短名称:mgwindowsdx)
更改Game1.cs的两个方法:
复现步骤:运行之后切换按下回车键 异常: Unhandled exception. SharpGen.Runtime.SharpGenException: HRESULT: [0x80004002], Module: [Unknown], ApiCode: [Unknown/Unknown], Message: 不支持此接口
at SharpGen.Runtime.Result.ThrowFailureException() at SharpGen.Runtime.ComObject.QueryInterface[T]() at ImeSharp.TextServicesContext.get_ThreadManager() at ImeSharp.TextServicesContext.RegisterTextStore(TextStore defaultTextStore) at ImeSharp.TextStore.get_Current() at ImeSharp.TextServicesContext.SetFocusOnDefaultTextStore() at ImeSharp.InputMethod.EnableOrDisableInputMethod(Boolean bEnabled) at ImeSharpOnMonogame.Game1.Update(GameTime gameTime) in D:\Notran\ImeSharpOnMonogame\ImeSharpOnMonogame\Game1.cs:line 57 at Microsoft.Xna.Framework.Game.DoUpdate(GameTime gameTime) at Microsoft.Xna.Framework.Game.Tick() at MonoGame.Framework.WinFormsGameWindow.TickOnIdle(Object sender, EventArgs e) at System.Windows.Forms.Application.ThreadContext.Interop.Mso.IMsoComponent.FDoIdle(msoidlef grfidlef) at System.Windows.Forms.Application.ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(UIntPtr dwComponentID, msoloop uReason, Void* pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at MonoGame.Framework.WinFormsGameWindow.RunLoop() at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) at Program.$(String[] args) in D:\Notran\ImeSharpOnMonogame\ImeSharpOnMonogame\Program.cs:line 6
我试过把 WindowsDX 换成 DesktopGL, 但是仍会抛出此异常