Creating Custom Attributes in Visual Basic .NET
Creating the Attribute Project
You can define a class in any project and any source file. Technically, attributes are just classes. However, because you use attributes to decorate elements of code, you may want to use them in more than just one particular project. For this reason, it's a good idea to create attributes in a separate class library assembly.
You can use the Class Library project template to create a new class library project. The Class Library project template uses the Wizard Engine to make a copy of a .vb file and project containing an empty class. You can use this as a starting point for defining a custom attribute that conveys information about the kind of control you may want to associate with a property. The general idea is that you might create an attribute like this if you were inclined to create an application generator. Be sure to provide a meaningful name for the project; I named the class in Listing 1 ControlDesignerAttribute.
Listing 1The ControlDesignerAttribute Class Is Our Beginning Point
Public Class ControlDesignerAttribute End Class
TIP
By convention, attributes have an Attribute suffix when the attribute is defined. Also by convention, the Attribute suffix is dropped when you apply the attribute.