私は今まで見た中で最も奇妙なバグの 1 つを持っています。
ゼロから作成されたこの Windows フォーム アプリケーションを見てください。
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
System.Windows.Forms.Clipboard.Clear();
}
}
ボタンがクリックされたときにクリップボードをクリアするだけです。
ここで、これを Visual Studio のデバッグで実行し、クリップボードを数回クリアしてからアプリを閉じてから Visual Studio を閉じようとすると、Visual Studio が「メモリ破損」例外でクラッシュします。これは 100% 発生するわけではありませんが、発生した場合、Visual Studio を起動することさえできなくなり、再起動する必要があります。
これは Outlook にも影響するようです。Outlook を開いている場合は、このアプリを起動し、クリップボードを数回クリアしてから Outlook に戻すと、Outlook もクラッシュし、Visual Studio と同様に、再起動して再度使用できるようにする必要があります。
そのため、このメソッドで Windows フォーム クリップボード クラスが何をするのか非常に疑わしく感じ始めていますClear()
。私の理論を確認するために、WPF に付属の Clipboard クラスを使用しました。WinForms アプリケーションで PresentationCore.dll を参照し、以下を置き換えました。
System.Windows.Forms.Clipboard.Clear();
と
System.Windows.Clipboard.Clear();
そして今、Visual Studio も Outlook もクラッシュしません。
私はこれを少しグーグルで検索しましたが、問題の明確な解決策がないこの投稿を見つけました。
私の質問は、これは WinForms クリップボード クラスの本当のバグですか、それとも何か不足しているのでしょうか?
追加情報:
- ビジュアル スタジオ 2012
- .NET 4.0 で実行されているプロジェクト。
- アウトルック 2010
Outlook クラッシュ コールスタック:
Unhandled exception at 0x77a7e3be in OUTLOOK.EXE: 0xC0000005:
Access violation reading location 0x5c83d763.
ntdll.dll!@RtlpLowFragHeapFree@8() + 0x2c bytes
ntdll.dll!_RtlFreeHeap@12() + 0x7e bytes
kernel32.dll!_HeapFree@12() + 0x14 bytes
mshtml.dll!ParseExpandProperty() + 0x2d6 bytes
mshtml.dll!PROPERTYDESC::HandleStyleComponentProperty() - 0xc2707 bytes
mshtml.dll!MSCSSParser::SetStyleProperty() + 0x268 bytes
mshtml.dll!MSCSSParser::Declaration() + 0x95 bytes
mshtml.dll!MSCSSParser::Write() + 0x8b0 bytes
mshtml.dll!BaseCSSParser::LoadFromStream() + 0x15a bytes
mshtml.dll!CStyleSheet::DoParsing() + 0x18b bytes
mshtml.dll!CStyleElementHelper::OnDwnChan() + 0x315 bytes
mshtml.dll!CStyleElementHelper::SetCssCtx() - 0x130a5f bytes
mshtml.dll!CStyleElementHelper::EnsureStyleDownload() + 0xfd bytes
mshtml.dll!CStyleElementHelper::AttachExternalStyleSheet() + 0x97 bytes
mshtml.dll!CLinkElement::HandleLinkedObjects() + 0xf0 bytes
mshtml.dll!CLinkElement::Notify() - 0x189c54 bytes
mshtml.dll!CHtmRootParseCtx::FlushNotifications() + 0x134 bytes
mshtml.dll!CHtmRootParseCtx::Commit() + 0xb bytes
mshtml.dll!CHtmParse::Commit() + 0x3c bytes
mshtml.dll!CHtmPost::Broadcast() + 0xf bytes
mshtml.dll!CHtmPost::Exec() + 0x11c bytes
mshtml.dll!CHtmPost::Run() + 0x40 bytes
mshtml.dll!PostManExecute() + 0x8e bytes
mshtml.dll!PostManResume() + 0x96 bytes
mshtml.dll!CHtmPost::OnDwnChanCallback() + 0x10 bytes
mshtml.dll!CDwnChan::OnMethodCall() + 0x1f bytes
mshtml.dll!GlobalWndOnMethodCall() + 0xf8 bytes
mshtml.dll!GlobalWndProc() + 0x4517a bytes