我正在尝试使用微软翻译器,每次尝试创建时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”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。
有什么建议么?