加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何将system.serviceModel放入ServiceConfiguration.cscfg(Wind

发布时间:2020-12-14 03:52:36 所属栏目:Windows 来源:网络整理
导读:我有以下代码(适用于Microsoft Translator) system.serviceModel bindings basicHttpBinding binding name="BasicHttpBinding_LanguageService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCoo
我有以下代码(适用于Microsoft Translator)

<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中运行良好.现在我需要将一些translate函数放到Azure Worker Role中,所以我收到错误找不到引用ServiceModel客户端配置部分中的合同’TranslatorService.LanguageService’的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素.

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

解决方法

ServiceConfiguration.cscfg只能包含Azure特定配置(如实例数,配置设置,指纹……).

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

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

  ...

</configuration>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读