【问题标题】:namespace name soapcontext could not be found找不到命名空间名称soapcontext
【发布时间】:2014-02-27 00:30:31
【问题描述】:

我正在构建一个调用第三方 Web 服务的表单应用程序,但不断收到 "namespace name soapcontext could not be found" 错误。

我已经添加了一个指向 Web 服务的 wsdl 的 Web 引用。这是我所拥有的:

private void btnGetInfo_Click(object sender, EventArgs e)
{
     QTWebSvcsService svc = new qtref.QTWebSvcsService();
     // The getVehicleInformation method accepts an AssetIdentifier and returns a
     // VehicleInfo object.  Instantiate them both.
     qtref.AssetIdentifier ai = new qtref.AssetIdentifier();
     qtref.VehicleInfo vi = new qtref.VehicleInfo();

     // Replace these strings with valid company name, user name and password
     string sUsername = "[usernasme]";
     string sCompanyname = "[company]";
     string sIdentity = sUsername + "@" + sCompanyname;
     string sPassword = "[password]";

     //This is where it fails
     SoapContext requestContext = RequestSoapContext.Current;
}

这是确切的错误:

Error   1   The type or namespace name 'SoapContext' could not be found (are you missing a using directive or an assembly reference?)   C:\Users\Sophia Carter\Documents\Visual Studio 2010\Projects\DemoGetVehInf\DemoGetVehInf\Form1.cs   45  13  DemoGetVehInf

【问题讨论】:

    标签: c# web-services soap visual-c#-express-2010


    【解决方案1】:

    根据错误,您似乎需要一个 using 语句来包含包含 SoapContext 的命名空间。 我不知道这将是什么命名空间,但在您的代码顶部,您将放置如下内容:

    using SoapContextNamespace;
    

    我个人将 Visual Studio 与 ReSharper 一起使用。这种工具组合可以检测到这个错误,并提供一种方法来纠正它,方法是在您右键单击时从上下文菜单中选择一些内容。根据您的工具集,您可能会找到此选项或类似选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-28
      • 1970-01-01
      • 2016-06-14
      • 2017-07-12
      相关资源
      最近更新 更多