ユーザーがこれと同じ問題を抱えているいくつかの投稿を読みました。コンパイルすると、.exeはapp.configからリソースをロードできなくなります。これは、app.configが出力ディレクトリにコピーされている場合でも発生します。
具体的には、次のように静的にコンパイルしても、Webサービスクライアントが適切なエンドポイント構成を判別できないという問題があります。
this.ws = new MyServicePortTypeClient("MyServicePort", "http://mysite.com/customer_portal/ws.php");
スローされた例外は、「System.InvalidOperationException:ServiceModelクライアント構成セクションでコントラクト'MyWebService.MyServicePortType'を参照するデフォルトのエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、これに一致するエンドポイント要素がなかったことが原因である可能性があります。契約はクライアント要素にあります。」
私は途方に暮れているので、どんな助けもいただければ幸いです。
編集:これがMyService.exe.configです
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyServiceBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://mysite.com/customer_portal/ws.php"
binding="basicHttpBinding" bindingConfiguration="MyServiceBinding"
contract="MyWebService.MyServicePortType" name="MyServicePort" />
</client>
</system.serviceModel>
</configuration>