开发者

“Could not find default endpoint element that references contract”

While calling webservice during uninstallation of windows application I am getting error as

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.

I am using Installer class in which I am calling webservice client. Following is code of installer.cs

Source code :

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);


    }

}

}开发者_如何学运维

Where unInstallOperation() will call webservice operation which contains updation of account.

How to solve this issue? Really feedup with this issue

I have no problem when i call serviceclient from another page or from another class file it give me problem when I am calling during uninstallation of application i.e in Installer class. This is app.config client configuration code that i have used

source code:

  <client> 

  <endpoint address="http://companyfind.info/RegWcfService/Service1.svc" 
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
      contract="IService1" name="BasicHttpBinding_IService1" />

   </client>

Is there any need to add this in web.config file of web service??


You probably need to use the name of your endpoint when you are instatiating Service1Client

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

Or, as it was in my case, you have your another class in another project in solution and two app.config classes. So, you need to copy/paste the desription af enpoints and bindings in main app.config.


Try to update the service reference, and check if client configuration is in the startup project config file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜