0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VisualStudioでクラスのアイコンが変で、開こうとするとデザイナエラーになる

Last updated at Posted at 2017-09-15

大昔に作られたクラスだが、ソリューションエクスプローラー上で見ると何だかアイコンが赤くて変な奴がいた(ActiveReportのデザインクラスと同じ)
なんだと思ってクリックして開こうとするとデザイナエラー・・・・

F7を押してコード側に行けば問題なく開発は進められたが、毎度やるのは微妙にめんどくさい・・・

というわけで調べたら下記の記事にて解決。

[VisualStudio]Componentを継承した.csクラスファイルを開くとデザイナで開こうとしてエラーになる

どうやらBackgroundWorkerを継承したクラスだったことが原因。
クラスにDesignerCategory("Code")の属性を付ければ解決しました。

Hoge.cs

[System.ComponentModel.DesignerCategory("Code")]
public class Hoge : BackgroundWorker
{

}

↓ 記事内にあるけど、これだけ超注意ですね。 ↓

上記の回答者も書いてくれているんだけど、謎なことに
属性の「System.ComponentModel」をusingに入れて省略して書いてしまうと
解決しない。
VisualStudioはusing無視しますよ、だそうだ。まじか。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?