3

在卸载 Windows 应用程序期间调用 webservice 时出现错误

在 ServiceModel 客户端配置部分中找不到引用合同 ServiceReference2.IService1' 的端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

我正在使用我正在调用 web 服务客户端的安装程序类。以下是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() 将调用包含更新帐户的 web 服务操作。

如何解决这个问题?真的厌倦了这个问题

当我从另一个页面或另一个类文件调用 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 文件中添加这个?

4

2 回答 2

5

当您启动 Service1Client 时,您可能需要使用端点的名称

var sc = new webMiner.ServiceReference2.Service1Client("BasicHttpBinding_IService1");

或者,就像我的情况一样,您在解决方案中的另一个项目中有另一个类和两个 app.config 类。因此,您需要在主 app.config 中复制/粘贴 enpoints 和 bindings 的描述。

于 2013-01-25T12:53:54.773 回答
0

尝试更新服务引用,并检查客户端配置是否在启动项目配置文件中。

于 2011-08-05T12:36:15.083 回答