LoginSignup
3
4

More than 5 years have passed since last update.

System.Windows.Forms.Clipboard.SetText("") は、死ぬ

Last updated at Posted at 2018-06-11

まあタイトルの通り。

System.Windows.Forms.Clipboard.SetText メソッドに、空文字列を渡すと例外になる。

なぜなのかは全然わからないけど、System.ArgumentNullException が発生する。

渡しているのは "" であって null ではないのに、なぜか System.ArgumentNullException になる。

対策は

  • 空文字列を SetText しないようにする
  • System.Windows.Clipboard.SetText() を代わりに使う

ぐらい。
バグっぽいけどどうなんだろう。

追記:
コメントに書いていただいているとおり、 MSDN に明記されているので仕様らしい。しかし不適切な仕様だと思う。

3
4
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4