Type 'ConnectionOptions' is not defined

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Type 'ConnectionOptions' is not defined

    Hello.

    I´ve following Problem. I try to use WMI in an ASP.NET Site. But I get still
    this error:




    Server Error in '/ServerMon' Application.
    ----------------------------------------------------------------------------
    ----

    Compilation Error
    Description: An error occurred during the compilation of a resource required
    to service this request. Please review the following specific error details
    and modify your source code appropriately.

    Compiler Error Message: BC30002: Type 'ConnectionOptions' is not defined.

    Source Error:


    Line 1: Dim Options As New ConnectionOptions()


    Source File: D:\Inetpub\wwwroot\ServerMon\Default.aspx Line: 1

    How must i define the Connection Options. I´ve declared it! See below. I´m
    new to ASP.NET/VB.NET.

    I used the following Code:
    <%@ Page Language="VB" %>
    <%@ Import Namespace=System.Diagnostics %>
    <script runat="server">

    Sub Page_Load(Sender as Object, e as EventArgs)


    Dim Options As New ConnectionOptions()
    options.Username = "dom\user"
    options.Password = "password"

    Dim Scope As New ManagementScope("\\mcntr2\root\cimv2", options)
    Dim strSVCquery As String =
    ConfigurationSettings.AppSettings("NICquery")

    Dim objNICQuery As New wqlObjectQuery(strSVCquery)
    Dim objNICsearcher As New ManagementObjectSearcher(scope, objNICQuery)

    Dim envVar As New ManagementObject()
    Dim objNICItem As PropertyData
    Dim strNICColName As String

    scope.connect

    For Each envVar in objNICSearcher.Get
    For Each objNICItem in envVar.Properties
    strNICColName = objNICItem.Name
    Next
    Next


    End Sub

    --
    Semmelmann Andreas
    Krones AG
    mailto:semmelmann.andreas@NOSPAMkrones.de


    Andreas Semmelmann Guest

  2. Similar Questions and Discussions

    1. Using User Defined Data Type Across
      hi! i have created a document class. I have a .net client application and a web service. Both of them using same object model and referencing a...
    2. index on user defined type
      I think I created a type that was compatible with the btree index, and everything seems fine, except that it doesn't actually use the index. I...
    3. Type 'DataGridPageChangedEventArgs' is not defined
      In my code-behind page I have this routine. What do I have to do for it to recognize DataGridPageChangedEventArgs? Sub PageIndexChanged(ByVal...
    4. BC30002: Type 'DataRowView' is not defined.
      Hi I get this error when I try to run my Page which has nested DataGrid. <asp:DataGrid id=DataGrid2 runat="server" AutoGenerateColumns="False"...
    5. type AssemblyTitle is not defined
      Hi, You are missing an Import to System.Reflaction or reference (not import) to System.Reflaction.Dll. In .Net you must to reference the...
  3. #2

    Default Re: Type 'ConnectionOptions' is not defined

    Hi,

    you probebly missing reference to System.Management.dll assembly.

    Natty Gur, CTO
    Dao2Com Ltd.
    34th Elkalay st. Raanana
    Israel , 43000
    Phone Numbers:
    Office: +972-(0)9-7740261
    Fax: +972-(0)9-7740261
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: Type 'ConnectionOptions' is not defined

    Hi Natty

    I´ve imported the System.Managment. I´ve used the following code:

    <%@ Page Language="VB" Debug="true" %>
    <%@ import Namespace="System" %>
    <%@ import Namespace="System.IO" %>
    <%@ import Namespace="System.Management" %>
    <script runat="server">

    Sub Page_Load(obj as object, e as eventargs)

    On Error Resume Next

    'This script uses Windows Management Instrumentation (WMI)
    'to return a list of properties for the a specified drive
    'attached to the server.
    Dim sDriveLetter As String
    Dim DiskProperties As PropertyDataCollection
    Dim DiskProperty

    'Drive letter for which to show drive properties
    sDriveLetter = "C:"

    Dim disk As New ManagementObject("win32_logicaldisk.deviceid=""" &
    _
    sDriveLetter & """")
    disk.Get()

    Response.write("<H2>Properties of Drive " & sDriveLetter & "</H2>")

    'Retrieve the disk's properties
    DiskProperties = disk.Properties

    'Iterate through the disk's properties
    For Each DiskProperty In DiskProperties

    'Check whether the particular property is defined for this
    drive
    If IsDBNull(DiskProperty.Value.ToString()) Then
    Response.Write("<FONT COLOR=""blue"">" & DiskProperty.Name &
    _
    "</FONT> = &lt;not defined&gt;<BR>")

    Else

    Response.Write("<FONT COLOR=""blue"">" & DiskProperty.Name &
    _
    "</FONT> = <FONT COLOR=""red"">" & _
    DiskProperty.Value.ToString() & "</FONT><BR>")
    End If


    Next

    disk = nothing

    End Sub

    "Natty Gur" <natty@dao2com.com> schrieb im Newsbeitrag
    news:urs7MiBYDHA.2152@TK2MSFTNGP09.phx.gbl...
    > Hi,
    >
    > you probebly missing reference to System.Management.dll assembly.
    >
    > Natty Gur, CTO
    > Dao2Com Ltd.
    > 34th Elkalay st. Raanana
    > Israel , 43000
    > Phone Numbers:
    > Office: +972-(0)9-7740261
    > Fax: +972-(0)9-7740261
    > Mobile: +972-(0)58-888377
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Andreas Semmelmann Guest

  5. #4

    Default Re: Type 'ConnectionOptions' is not defined

    Hi,

    You import the System.Managment but that’s no enough. Imports simply let
    you access class without full name (using namespace). To enable ASP.NET
    to know type a reference to the assembly that holds that type is
    necessary. Add reference by using "Add reference" sub menu under
    "project" menu.

    Natty Gur, CTO
    Dao2Com Ltd.
    34th Elkalay st. Raanana
    Israel , 43000
    Phone Numbers:
    Office: +972-(0)9-7740261
    Fax: +972-(0)9-7740261
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  6. #5

    Default Re: Type 'ConnectionOptions' is not defined

    Hi.

    Are these settings for Visual Studio .NET? I think so. Do you know the
    aproppriate setting for ASP.NET Web Matrix?
    As I told you in a former posting, I´m very new to .NET programming. You
    must talk to me like I was a fool! Thanks a lot.


    "Natty Gur" <natty@dao2com.com> schrieb im Newsbeitrag
    news:%23hJnHcJYDHA.384@TK2MSFTNGP12.phx.gbl...
    > Hi,
    >
    > You import the System.Managment but that's no enough. Imports simply let
    > you access class without full name (using namespace). To enable ASP.NET
    > to know type a reference to the assembly that holds that type is
    > necessary. Add reference by using "Add reference" sub menu under
    > "project" menu.
    >
    > Natty Gur, CTO
    > Dao2Com Ltd.
    > 34th Elkalay st. Raanana
    > Israel , 43000
    > Phone Numbers:
    > Office: +972-(0)9-7740261
    > Fax: +972-(0)9-7740261
    > Mobile: +972-(0)58-888377
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Andreas Semmelmann Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139