Topic:   Facing error "Type 'ManagementObjectSearcher' is not defined" when i am using this code
Oct 16, 2020 06:53 1 Replies 7 Views PADMAKEECHU

Imports System.Management

Imports System.Management.Instrumentation 

Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled=true")

Dim objects As IEnumerable(Of ManagementObject) = searcher.[Get]().Cast(Of ManagementObject)()

Dim mac As String = (From o In objectsOrder By o("IPConnectionMetric")o("MACAddress").ToString()).FirstOrDefault()

lblMacId.Text = mac

Prev Next
Topic Replies (1)
  1. 1
    idnkx user

    PARTH

    Add the System.Management dll reference to the project.

    Right click on Solution Explorer -> Add Reference
    Under the .Net tab select System.Management and click OK.

    Then add the namespace as shown below -
    Imports System.Management

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let's Connect