?
Solved

VB.net 'ManagementObjectCollection' is not defined.

Posted on 2014-02-28
3
Medium Priority
?
615 Views
Last Modified: 2014-03-01
Hi

I get the following errors in the code below. What references/imports do I have to make

  Error      81      Type 'ManagementObjectCollection' is not defined.
Error      82      Type 'ManagementObject' is not defined.
Error      80      Type 'ManagementClass' is not defined.


  Friend Function GetAllMACAddresses() As String

        Dim mc As ManagementClass = New ManagementClass("Win32_NetworkAdapterConfiguration")
        Dim moc As ManagementObjectCollection = mc.GetInstances()
        Dim MACAddress As String = String.Empty
        For Each mo As ManagementObject In moc
            If CBool(mo("IPEnabled")) Then MACAddress &= mo("MacAddress").ToString() & ";"
            mo.Dispose()
        Next
        Return MACAddress.Trim.Trim(";").Trim
    End Function
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 1000 total points
ID: 39895161
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1000 total points
ID: 39895698
What kaufmed implies is that you need to first define a reference to the System.Management.dll in through the Project...Add Reference menu, so that Visual Studio recognize that class.

Then, you should add an Imports System.Management command at the top of the file so that the compiler recognizes that namespace.

You must do that whenever you use classes out of the "ordinary" classes that are used more regularly.
0
 

Author Closing Comment

by:Murray Brown
ID: 39896892
Thank you both
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question