3

Windowsアプリケーションのアンインストール中にWebサービスを呼び出すと、次のようなエラーが発生します。

ServiceModelクライアント構成セクションでコントラクトServiceReference2.IService1'を参照するエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、この名前に一致するエンドポイント要素がクライアント要素で見つからなかったことが原因である可能性があります。

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()は、アカウントの更新を含むWebサービス操作を呼び出します。

この問題を解決するにはどうすればよいですか?本当にこの問題にうんざりしている

別のページまたは別のクラスファイルからserviceclientを呼び出すと、問題は発生しません。アプリケーションのアンインストール中、つまりインストーラークラスで呼び出すと問題が発生します。これは私が使用した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");

または、私の場合のように、ソリューション内の別のプロジェクトに別のクラスと 2 つの app.config クラスがあります。そのため、メイン app.config の enpoints とバインディングの説明をコピーして貼り付ける必要があります。

于 2013-01-25T12:53:54.773 に答える
0

サービス参照を更新して、クライアント構成がスタートアップ プロジェクトの構成ファイルにあるかどうかを確認してください。

于 2011-08-05T12:36:15.083 に答える