2014-02-27 140 views
0

我正在构建一个表单应用程序,它可以调用第三方Web服务,但不断收到"namespace name soapcontext could not be found"错误。名称空间名称无法找到soapcontext

我已经添加了一个指向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 

回答

0

,它看起来像你需要一个using语句来包括包含SoapContext的命名空间。 我不知道这会是什么命名空间,但在你的代码的顶部,你将会把这样的:

using SoapContextNamespace; 

我个人使用Visual Studio中的ReSharper。这种工具组合检测到这个错误,并提供了一种方法来纠正它,当你点击右键时从上下文菜单中选择一些东西。根据您的工具集,您可能会发现这个或类似的选项。

相关问题