What is the My namespace in VB.NET?

VB.NET Language Basic 1–2 Yrs2–3 Yrs Conceptual 1 min read

Quick Answer

My is a VB.NET convenience namespace that surfaces common framework functionality through a simple, discoverable API — My.Settings, My.Application, My.Computer.FileSystem, My.Resources, My.User. It's compiler-generated sugar over the underlying .NET classes; C# has no equivalent (you call the classes directly).

My is a VB.NET-only shortcut namespace that wraps common tasks in an easy-to-find API — My.Settings for configuration, My.Computer.FileSystem for file access, My.Application for app info and logging, My.Resources for embedded resources. The compiler generates it; it's just calling the normal .NET classes underneath. It's handy for internal VB.NET apps, but if the code needs to be understood alongside C# I'd use the underlying framework types directly.

  • My.Settings.LastFolder — strongly typed access to app/user settings.
  • My.Computer.FileSystem.ReadAllText(path) — wrappers over System.IO.
  • My.Application.Info.Version, My.Application.Log.
  • My.Resources.Logo — embedded resources.
  • It's fine for line-of-business VB.NET, but code you might share with C# or move cross-platform should use the underlying BCL types directly.