Microsoft & .NETVisual BasicYour Introduction to the My Object in VS 2005

Your Introduction to the My Object in VS 2005 content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

VB can be a completely object-oriented language and still find ways to enhance productivity. One of the ways that Microsoft is still finding innovative ways to increase productivity without making VB.NET a second-class language is the introduction of the My object, which will ship in VS 2005 and is available in Beta 1 versions of VB 2005. This article introduces this new object.

Classes in My Object

My is an object like Me, but instead of being a self-referencing object it is a wrapper that makes getting at the advanced features of .NET easier. If you found using advanced features such as the ResourceManager and WebServices confusing, or even reading information from the AssemblyInfo file, then you are going to love My.

Note: The actual nomenclature for My is still being decided. Currently, the correct word to describe My is feature. It remains to be seen whether Microsoft will call My an object, namespace, or something else when it releases VS 2005.

My contains Application, Computer, Resources, User, and WebServices wrapper objects that act like shortcuts to powerful and useful features of .NET. You can use these features without creating instances of the classes they wrap and without mastering arcane subjects like reflection first. Don’t misunderstand me: One should learn reflection because it is a powerful tool, but lowering the barrier to entry is a classic VB response to complex subjects.

Setting AssemblyInfo Information

Rather than try to cover everything My offers, I picked just one facet, the AssemblyInfo class, as a vessel for introducing this neat feature. The AssemblyInfo class is a wrapper for the AssemblyInfo.vb file that VB 2005 adds to every project. The AssemblyInfo class makes it easy to obtain information about your project, such as title, copyright, and version information. A classic use for this information is to create an About dialog for your Windows Forms applications.

Early versions of VB.NET used assembly-level attributes and code to incorporate things like version information into VB assemblies. In the new version, Microsoft created an easy-to-use dialog box (see Figure 1) that permits you to add assembly information to your .NET applications. You set this information by selecting Project|Properties from the menu. This opens your project properties dialog. In that dialog, select the Application tab and click the Assembly Information button. Simply fill out the dialog and click OK.

Figure 1: Add Assembly Information Using This Dialog Form

Reading My.Application.AssemblyInfo

Reading the assembly information has always been easier in VB than in C# because the Microsoft.VisualBasic.dll assembly is always part of your VB applications. In current editions of VB, you have to create an AssemblyInfo object, passing the executing assembly as a parameter. In VB 2005, all you have to do is access the ubiquitous My object, referring to My.Application.AssemblyInfo, and you have immediate, one-line access to your assembly’s information (see Listing 1).

Listing 1: Access Information About an Assembly with a Single Line of Code

Module Module1

   Sub Main()
   End Sub

End Module

Ease of use is what VB always has been about. By building the new VB on top of the powerful .NET framework, VB can be both easy to use and powerful.

New VB 2005 Feature

The My object encapsulates many of the advanced features of .NET into a consolidated wrapper package that makes these features easier to access—often with a single line of code. Pick up a beta copy of VS 2005 today and you will discover My and many other new features that increase your productivity and enjoyment.

About the Author

Paul Kimmel is the VB Today columnist for and has written several books on object-oriented programming and .NET. Check out his book Visual Basic .NET Power Coding from Addison-Wesley and his upcoming book UML DeMystified from McGraw-Hill/Osborne (Spring 2005). Paul is also the founder and chief architect for Software Conceptions, Inc, founded 1990. He is available to help design and build software worldwide. You may contact him for consulting opportunities or technology questions at

If you are interested in joining, sponsoring a meeting, or posting a job, check out, the Web page of the Greater Lansing area Users Group for .NET.

Copyright © 2005 by Paul Kimmel. All Rights Reserved.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories