473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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:se****************@NOSPAMkrones.de
Nov 17 '05 #1
4 2833
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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
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" <na***@dao2com.com> schrieb im Newsbeitrag
news:ur**************@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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3
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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4
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" <na***@dao2com.com> schrieb im Newsbeitrag
news:%2***************@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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Terje Slettebø | last post by:
Hi. I'm new here, and sorry if this has been discussed before; I didn't find it searching the PHP groups. (I've also read recommendations to cross-post to the other PHP groups, but if that is...
4
by: Jari Kujansuu | last post by:
I can successfully parse XML document using SAX or DOM and I can also validate XML document against schema. Problem is that my program should deal with user-defined schemas which means that when...
4
by: Jacob Jensen | last post by:
This question has probably been asked a million time, but here it comes again. I want to learn the difference between the three type cast operators: static_cast, reinterpret_cast, dynamic_cast. A...
21
by: Nitin Bhardwaj | last post by:
Hi all, It is said that C++ is a strongly typed language and thus a type-safe language (unlike C). So how does one explain the following behaviour : int main(void) { char *p = NULL; p = "A...
8
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
13
by: dawatson833 | last post by:
I have several stored procedures with parameters that are defined with user defined data types. The time it takes to run the procedures can take 10 - 50 seconds depending on the procedure. If I...
7
by: Michael | last post by:
Hi, I could understand the difference between class and object. However, I could find out a good definiton of type. how to understand the relaitonship between type, class, and object? Thanks! ...
70
by: garyusenet | last post by:
I'm using an example piece of code: - namespace Wintellect.Interop.Sound{ using System; using System.Runtime.InteropServices; using System.ComponentModel; sealed class Sound{ public static...
4
by: DKn | last post by:
Hello all, How this Timeout option is useful ? When i am going for WMI connection i have given this Timeout option , Still for connection is taking 5 to 6 seconds. ConnectionOptions.Timeout...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.