.net 4.5 ベースの Visual Studio 2013 で新しい dll アプリケーションを作成しています。Guid
次のようにクラスで属性を定義しようとすると:
[Guid("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]
コンパイラは私にエラーを与えます
「System.Guid」は属性クラスではありません。
何が欠けているか分かりますか?
.net 4.5 ベースの Visual Studio 2013 で新しい dll アプリケーションを作成しています。Guid
次のようにクラスで属性を定義しようとすると:
[Guid("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]
コンパイラは私にエラーを与えます
「System.Guid」は属性クラスではありません。
何が欠けているか分かりますか?
System.Runtime.InteropServices
次のように、への参照を追加する必要があります。
using System.Runtime.InteropServices;
または、クラスの完全な名前を述べます。
[System.Runtime.InteropServices.Guid("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]
または接尾辞でクラス名を使用しますAttribute
:
[GuidAttribute("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]
または接尾辞付きの完全なクラス名を使用しますAttribute
:
[System.Runtime.InteropServices.GuidAttribute("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]
詳細については、MSDN の記事を参照してください。
You should include the correct namespace or using
statement. If you don't do that, it will match System.Guid
(instead of System.Runtime.InteropServices.GuidAttribute
, the Attribute
part is stripped out for our convenience), which indeed isn't an attribute. It's a little confusing, but true...
This code will get you there:
[System.Runtime.InteropServices.Guid("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]