0
Error 2 The type or namespace name 'ConnectionOptions' could not be found (are you missing a using directive or an assembly reference?)
C:\Users\user\Documents\Visual Studio 2010\WebSites\Service\App_Code\PService.cs    55  10  C:\...\Service\

尝试使用代码时

 [WebMethod]
 public ConnectionOptions remoteconnection(string MyComputerName, string ip)
 {
     ConnectionOptions connOptions = new ConnectionOptions();

     return connOptions ;

 }

虽然在 webApplication 中复制相同的代码时没有错误。我在两个文件中都使用了 system.Management 。

4

1 回答 1

1

您定义了 System.Managment 的命名空间,但这还不够。定义只是让您访问没有全名的类(使用命名空间)。要使 ASP.NET 知道类型,需要对包含该类型的程序集的引用。使用“项目”菜单下的“添加参考”子菜单添加参考。然后检查 System.Management 项并添加您的项目的引用。

于 2016-05-25T00:00:47.363 回答