Click here to Skip to main content
11,790,987 members (61,174 online)
Click here to Skip to main content

Using the VB.NET My Namespace in C# .NET 2.0

, 20 Jan 2006 CPOL 51.3K 339 17
Rate this:
Please Sign up or sign in to vote.
In VB.NET 2.0, we have a new namespace, My, that exposes some nice classes. This article shows you how to access this namespace in C#


I just happened to run across this in a Visual Studio 2005 help file.  I had seen all the hype for VB.NET 2.0 with the new My namespace, and I thought that might be nice to use in C#.  This article follows the simple steps I found in the Visual Studio help file to do just that.


You might ask why I was looking through the Visual Studio 2005 help files?  I was reading up on some topics that I thought would help me be a little more ready for the next Microsoft certification upgrade tests.  Anyway, I was looking through the namespace help just to see if there was anything interesting.  I ran across this example and thought I would write an article on it so others could benefit.

The Code

It is really quite simple.  First you need to add a reference to the Visual Basic Library.  I know it makes me a little nervous too.

Adding a reference to the Visual Basic dll

Next, add a using clause:

using Microsoft.VisualBasic.Devices;

Finally use the MyServices namespace:

Computer myComputer = new Computer();

There are quite a few cool things (classes) in the namespace. Here is a short list:

  • Audio
  • Clipboard
  • Clock
  • FileSystem
  • Info
  • Keyboard
  • Mouse
  • Name
  • Network
  • Ports
  • Registry
  • Screen


The help file mentions that there are some classes that were not compatible.  The example they gave was FileSystemProxy.

The link to the help file is: ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_csref/html/e7152414-0ea5-4c8e-bf02-c8d5bbe45ff4.htm.

The title is: C# Programmer's Reference
How to: Use the My Namespace (C# Programming Guide)


So I hope you find this useful.  I don't think I will be using this in every project, but it is nice to know that you can do it when you need to.


  • 20th January, 2006: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
United States United States
I started my programmer career over 19 years ago doing COBOL and SAS on a MVS mainframe. It didn't take long for me to move into windows programming. I started my windows programming in Delphi (Pascal) with a Microsoft SQL server back end. I started working with when the beta 2 came out in 2001. After spending most of my programming life as a windows programmer I started to check out in 2004. I achieved my in April 2005. I have done a lot of MS SQL database stuff. I have a lot of experience with Window Service and Web services as well. I spent three years as a consultant programing in C#. I really enjoyed it and found the switch between and C# to be mostly syntax. In my current position I am programming in both and C#. Lately I have been using VS2012.

On a personal note I am a born again Christian, if anyone has any questions about what it means to have a right relationship with God or if you have questions about who Jesus Christ is, send me an e-mail. ben.kubicek[at]netzero[dot]com You need to replace the [at] with @ and [dot] with . for the email to work. My relationship with God gives purpose and meaning to my life.

You may also be interested in...

Comments and Discussions

Questionnot all functions Pin
XPUCTUAHUH15-Apr-08 23:25
memberXPUCTUAHUH15-Apr-08 23:25 
GeneralRe: not all functions Pin
kubben16-Apr-08 1:45
memberkubben16-Apr-08 1:45 
GeneralRe: not all functions Pin
XPUCTUAHUH16-Apr-08 2:23
memberXPUCTUAHUH16-Apr-08 2:23 
GeneralWell done Pin
D Strauss20-Jun-07 10:45
memberD Strauss20-Jun-07 10:45 
Hey kubben. Well done. I was wondering if C# applications could reference the My namespace. After all, why should VB.NET programmers have all the fun.Big Grin | :-D
I've been programming in VB.NET for 5 years and for the last year switched over to C#.NET. The migration wasn't that painfull. I enjoy C# tremendously. It is really liberating having the freedom to being able to develop applications in VB.NET or C#. On the Christian side of things, I too am a Christian. It's wonderfull seeing you so open about it on your profile. "If you acknowledge Me before men, I will acknowledge you before My Father." Rock on brother!Cool | :cool:
GeneralRe: Well done Pin
kubben20-Jun-07 12:33
memberkubben20-Jun-07 12:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1509028.1 | Last Updated 20 Jan 2006
Article Copyright 2006 by kubben
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid