C# 找不到命名空间名称soapcontext
我正在构建一个表单应用程序,该应用程序调用第三方web服务,但不断得到一个C# 找不到命名空间名称soapcontext,c#,web-services,soap,visual-c#-express-2010,C#,Web Services,Soap,Visual C# Express 2010,我正在构建一个表单应用程序,该应用程序调用第三方web服务,但不断得到一个“名称空间名称soapcontext找不到”错误 我已经添加了一个指向web服务wsdl的web引用。以下是我所拥有的: private void btnGetInfo_Click(object sender, EventArgs e) { QTWebSvcsService svc = new qtref.QTWebSvcsService(); // The getVehicleInformation
“名称空间名称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
根据错误,您似乎需要一个using语句来包含包含SoapContext的命名空间。 我不知道这将是什么名称空间,但在代码顶部,您将放置以下内容:
using SoapContextNamespace;
我个人使用visualstudio和ReSharper。这种工具组合可检测此错误,并提供一种在右键单击时从上下文菜单中选择某个内容来更正此错误的方法。根据您的工具集,您可能会发现此选项或类似选项