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ファイルに追加する必要はありますか?