2014-09-02 96 views
0

我遇到了一個用戶問題,我的應用程序只是拋出異常而沒有特別原因。我不確定是什麼導致了這種情況,因爲應用程序本身不檢查也不處理與輸入語言改變事件有關的任何事情。這個例外非常模糊,因爲它沒有內部異常或任何其他信息來說明發生了什麼,因爲它似乎是算術溢出異常。算術運算導致InputLanguageChangingEventArgs發生溢出

這裏是異常消息和堆棧跟蹤:

Type:  System.OverflowException 
Message:  算術演算の結果オーバーフローが発生しました。 
Source:  System.Windows.Forms 
Stack Trace: 場所 System.Windows.Forms.InputLanguageChangingEventArgs..ctor(InputLanguage inputLanguage, Boolean sysCharSet) 
    場所 System.Windows.Forms.Control.WmInputLangChangeRequest(Message& m) 
    場所 System.Windows.Forms.Control.WndProc(Message& m) 
    場所 System.Windows.Forms.ButtonBase.WndProc(Message& m) 
    場所 System.Windows.Forms.Button.WndProc(Message& m) 
    場所 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

異常消息爲「算術運算導致溢出」。有沒有人經歷過這樣的行爲

+0

這是一個環境問題,不是由您的代碼引起的任何問題。您的客戶必須再次讓自己的機器穩定下來,重點關注控制面板+語言中已安裝的語言。鑑於這是日本人,可能是某種自定義IME。 – 2014-09-02 09:25:07

回答

0

這實際上是.NET Framework中的一個錯誤之前,在System.Windows.Forms.InputLanguage.Culture吸氣(你不能看到它的堆棧跟蹤,因爲它得到由JIT內InputLanguageChangingEventArgs..ctor內聯):

public CultureInfo Culture 
{ 
    get 
    { 
     return new CultureInfo((int)this.handle & 65535); 
    } 
} 

這裏,this.handleIntPtr,這意味着它在x64操作系統上是64位的,但被錯誤地轉換爲int,並且如果設置了此handle中的某些較高位,則會導致OverflowException

我能想到的唯一解決方法是用handle沒有裝配到int類型完全過濾掉的消息:

// call this before Application.Run(): 
Application.AddMessageFilter(new WmInputLangChangeRequestFilter()); 

class WmInputLangChangeRequestFilter : IMessageFilter 
{ 
    public bool PreFilterMessage(ref Message m) 
    { 
     if (m.Msg == 0x0050) 
     { 
      return (long)m.LParam > 0x7FFFFFFF; 
     } 
     return false; 
    } 
} 
0

我在Greenshot,在那裏我研究這個,我來到這裏看到的「OverflowException異常」。

下面是一些附加信息的問題: MSDN上也有一些意見吧:https://msdn.microsoft.com/en-us/library/windows/desktop/ms632630(v=vs.85).aspx 據說在Windows的消息不是貼在如Windows 7,我可以證實我從來沒有見過它,不能再現它。

這裏也是一些信息,「什麼打破了輸入語言的消息?」:http://www.siao2.com/2006/05/16/598980.aspx

目前我認爲我的應用程序的消息並不重要,所以我加了Torvin的解決方案忽略它...

相關問題