Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'System.Guid' is not an attribute class

I am creating a new dll application with Visual Studio 2013 based on .net 4.5. When trying to define the Guid attribute on my class like this:

[Guid("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]

The compiler gives me the error

'System.Guid' is not an attribute class.

Any idea what's missing?

like image 388
codea Avatar asked Jan 09 '23 02:01

codea


1 Answers

You must add reference to the System.Runtime.InteropServices, like this:

using System.Runtime.InteropServices;

or state the full name for the class:

[System.Runtime.InteropServices.Guid("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]

or use class name with postfix Attribute:

[GuidAttribute("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]

or use full class name with postfix Attribute:

[System.Runtime.InteropServices.GuidAttribute("4245366B-0484-4A41-A2E8-C7D9FC3A4ED7")]

You can find more information on MSDN article

like image 135
VMAtm Avatar answered Jan 18 '23 15:01

VMAtm