4

我有以下代码(用于 Microsoft 翻译)

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_LanguageService" 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://api.microsofttranslator.com/V2/soap.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_LanguageService" contract="TranslatorService.LanguageService" name="BasicHttpBinding_LanguageService" />
        </client>
    </system.serviceModel>

web.config运行良好。现在我需要将一些翻译功能放到 Azure Worker Role,所以我得到了错误Could not find default endpoint element that references contract 'TranslatorService.LanguageService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

我已经找到解决方案是将上述设置设置为ServiceConfiguration.cscfg,但是如何?我尝试了很多位置,但所有错误都无法部署。请帮忙

4

1 回答 1

5

ServiceConfiguration.cscfg只能包含 Azure 特定配置(如实例数量、配置设置、指纹等)。

每当您需要进行常规 .NET 配置(例如 WCF)时,您只需为您的辅助角色创建一个app.config,就像您为控制台应用程序创建一个 app.config 并将您的配置放在这里一样。请注意,如果要将其添加到 app.config 中,则问题中的示例配置不完整。你应该把它包起来:

<?xml version="1.0"?>
<configuration>

  ...

</configuration>
于 2012-08-02T06:52:52.473 回答