解决方案:
打开web.config 配置文件 ctrl+f 键 查找"endpoint" 然后手工删除掉原有的才能正常运行。
错误原因:
当在vs 2010中添加服务引用后,如果“更新”服务引用,或“删除”该服务引用后再次加入后,在运行时会出现此错误。这是因为在“更新/删除”服务引用时,app.config文件并不会自动修改,在“更新”或再次“加入”后,会生成两个同样的“endpoint”,需要手工删除掉原有的才能正常运行。
using
System;using
System.Collections.Generic;using
System.Linq;using
System.Web;using
System.Web.UI;using
System.Web.UI.WebControls;namespace
WebUI.Page11{ public
partial class
手机号查询 : System.Web.UI.Page {
protected void
Page_Load(object
sender, EventArgs e)
{
}
protected void
Button1_Click(object
sender, EventArgs e)
{
MoblieServiceReference.MobileCodeWSSoapClient moblie =
new MoblieServiceReference.MobileCodeWSSoapClient();
string text = moblie.getMobileCodeInfo(this.TextBox1.Text,
"");
Response.Write(text);
} }} |
当代码执行到“MoblieServiceReference.MobileCodeWSSoapClient moblie = new MoblieServiceReference.MobileCodeWSSoapClient();“时抛出无法加载协定为“ServiceReference1.LanguageService””的终结点配置部分,因为找到了该协定的多个终结点配置。请按名称指示首选的终结点配置部分。
本文介绍了解决在Visual Studio 2010中更新或删除服务引用后出现的重复“endpoint”配置问题的方法。通过手动删除重复的配置,可以确保应用程序正常运行。
5万+

被折叠的 条评论
为什么被折叠?



