2014-02-27 115 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。這種工具組合檢測到這個錯誤,並提供了一種方法來糾正它,當你點擊右鍵時從上下文菜單中選擇一些東西。根據您的工具集,您可能會發現這個或類似的選項。

相關問題