Solved

VB.net 'ManagementObjectCollection' is not defined.

Posted on 2014-02-28
3
539 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:murbro
3 Comments
 
LVL 74

Assisted Solution

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

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 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:murbro
ID: 39896892
Thank you both
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now