Microsoft トランスレータを使用しようとしていますが、作成しようとするたびにLanguageServiceClient
エラーが発生します。
try
{
// Add the http header
string headerValue = GetAccessToken();
HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
httpRequestProperty.Method = "POST";
httpRequestProperty.Headers.Add("Authorization", headerValue);
TranslatorService.LanguageServiceClient client = new TranslatorService.LanguageServiceClient();
using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
{
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
result = client.Detect("", textToTranslate);
}
}
catch (Exception ex)
{
result = "Error: " + ex.Message;
}
エラー:
ServiceModel クライアント構成セクションで、コントラクト 'TranslatorService.LanguageService' を参照する既定のエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、このコントラクトに一致するエンドポイント要素がクライアント要素に見つからなかったためである可能性があります。
助言がありますか?