- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在卸载 Windows 应用程序期间调用 webservice 时出现错误
Could not find endpoint element that references contract ServiceReference2.IService1' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.
我正在使用调用 Web 服务客户端的 Installer 类。以下是installer.cs的代码
源代码:
namespace webMiner
{
[RunInstaller(true)]
public partial class demoInstaller : Installer
{
SqlConnection conn = new SqlConnection("Data Source=servername;Initial Catalog=comp;User Id=abc;Password=******;");
public demoInstaller():base()
{
InitializeComponent();
AfterUninstall += new InstallEventHandler(AfterUninstallEventHandler);
}
public override void Uninstall(System.Collections.IDictionary savedState)
{
base.Uninstall(savedState);
Int32 flag = -1;
string keyName = "";
RegistryKey regeditkey = Registry.CurrentUser.OpenSubKey("sevenuser", RegistryKeyPermissionCheck.ReadWriteSubTree);
keyName = regeditkey.GetValue("currentuser").ToString();
webMiner.ServiceReference2.Service1Client sc = new webMiner.ServiceReference2.Service1Client();
flag = sc.unInstallOperation(keyName);
}
}
其中 unInstallOperation() 将调用包含帐户更新的网络服务操作。
如何解决这个问题?真的对这个问题感到厌烦
当我从另一个页面或另一个类文件调用 serviceclient 时我没有问题,当我在卸载应用程序期间调用时给我带来问题,即在 Installer 类中。这是我用过的app.config客户端配置代码
源代码:
<client>
<endpoint address="http://companyfind.info/RegWcfService/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="IService1" name="BasicHttpBinding_IService1" />
</client>
是否需要在web服务的web.config文件中添加这个??
最佳答案
在实例化 Service1Client 时,您可能需要使用端点的名称
var sc = new webMiner.ServiceReference2.Service1Client("BasicHttpBinding_IService1");
或者,就像我的情况一样,您在解决方案的另一个项目中有另一个类和两个 app.config 类。因此,您需要在主 app.config 中复制/粘贴 enpoints 和绑定(bind)的说明。
关于wcf - “Could not find default endpoint element that references contract”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6955619/
我是一名优秀的程序员,十分优秀!