FatalExecutionEngineError或InvalidCastException

时间:2013-07-19 09:09:20

标签: c# wpf exception button gsm

我有一段代码可以从连接到我电脑的手机上读取信息。 代码是我复制的代码,它总是给我这两个错误 有时会说:

  

无法将“GsmComm.GsmCommunication.GsmPhone”类型的对象强制转换为“System.ComponentModel.ISynchronizeInvoke”。 (System.invlaid.Exception)

感谢您的帮助

private void btnRead_Click(object sender, RoutedEventArgs e)
{
    Mouse.OverrideCursor = Cursors.Wait;

    string storage = GetMessageStorageReading();

    try
    {
        DecodedShortMessage[] messages = CommSetting.comm.ReadMessages(PhoneMessageStatus.All, storage);

        foreach (DecodedShortMessage message in messages)
        {
            OutputReading(string.Format("Statut du message = {0}, Emplacement = {1}/{2}",
            StatusToString(message.Status), message.Storage, message.Index));
            ShowMessageReading(message.Data);
            OutputReading("");
        }

        OutputReading(string.Format("{0,9} message(s) lu(s).", messages.Length.ToString()));
        OutputReading("");
    }

    catch (Exception ex)
    {
        ShowException(ex);
    }

    Mouse.OverrideCursor = null;
}

0 个答案:

没有答案