0

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' を参照する既定のエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、このコントラクトに一致するエンドポイント要素がクライアント要素に見つからなかったためである可能性があります。

助言がありますか?

4

1 に答える 1

3

エラーを発見しました。

翻訳ロジックを実行するクラス ライブラリにサービス構成を配置していました。代わりに、Web サイト構成ファイル「web.config」に追加しようとしましたが、現在は機能しています。

于 2011-12-12T09:43:03.620 に答える