即使在 VB2005 项目中添加 System.Management 引用后,也未定义 ManagementObjectSearcher [英] ManagementObjectSearcher is not defined even after adding System.Management reference in VB2005 Project

查看:40
本文介绍了即使在 VB2005 项目中添加 System.Management 引用后,也未定义 ManagementObjectSearcher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中的 .aspx 页面的代码隐藏文件中有以下代码:

I have the following code on the code behind file for a .aspx page in a project:

Dim searcher As New ManagementObjectSearcher("SELECT RemoteName FROM win32_NetworkConnection WHERE LocalName = '" & sFilePath.Substring(0, 2) & "'")

    For Each managementObject As ManagementObject In searcher.[Get]()
        Dim sRemoteName As String = TryCast(managementObject("RemoteName"), String)
        sRemoteName += sFilePath.Substring(2)
        Return (New Uri(sRemoteName)).ToString()
    Next

    Return sFilePath

ManagementObjectSearcher 和 ManagementObject 都带有下划线,它告诉我它们没有定义.

The ManagementObjectSearcher and the ManagementObject are both underlined and it is telling me that they are not defined.

我添加了 System.Management 引用,删除并重新读取,删除了我的缓存,重建了整个 .aspx 页面,删除了 .dll 以及我在谷歌上找到的许多其他故障排除建议,但仍然找不到这个问题的答案.

I have added the System.Management reference, removed and readded, deleted my cache, rebuilt the whole .aspx page, removed the .dll and numerous other troubleshooting advise I have found on google but still cannot find the answer to this problem.

请帮忙!

推荐答案

像往常一样在项目顶部添加命名空间:

At the top of the project add in the namespace as you would normally:

Imports System.Management

然后在顶部的项目菜单下(在 Visual Studio 中)选择添加引用...".在.Net"选项卡下向下滚动到System.Management".选择该行并单击确定.

Then under the project menu at the top (in Visual Studio) select "Add Reference...". Under the ".Net" tab scroll down to "System.Management". Select that line and click OK.

这篇关于即使在 VB2005 项目中添加 System.Management 引用后,也未定义 ManagementObjectSearcher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆