【问题标题】:WCF Web Service error: The type 'ExampleTeste45.Web.Service.SilverlightWCF', provided asWCF Web 服务错误:类型“ExampleTeste45.Web.Service.SilverlightWCF”,提供为
【发布时间】:2014-09-11 11:44:56
【问题描述】:

在 Silverlight 项目中发布并尝试访问服务 http://griduni.uninova.pt/sidac/Service/SilverlightWCF.svc 时会收到出现的错误消息。

我的 Web.config

    <configuration>
        <system.web>
          <customErrors mode="Off"/>
          <compilation debug="true" targetFramework="4.5">
          </compilation>
          <httpRuntime targetFramework="4.5" />

        </system.web>


        <system.serviceModel>

          <!--<serviceHostingEnvironment>
            <baseAddressPrefixFilters>
              <add prefix="http://griduni.uninova.pt"/>
            </baseAddressPrefixFilters>
          </serviceHostingEnvironment>-->

            <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
                multipleSiteBindingsEnabled="true" />-->

            <bindings>
                <customBinding>
                    <binding name="ExampleTeste45.Web.Service.SilverlightWCF.customBinding0">
                        <binaryMessageEncoding />
                        <httpTransport />
                    </binding>
                </customBinding>
            </bindings>
            <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
                multipleSiteBindingsEnabled="true" />-->
            <services>
                <service name="ExampleTeste45.Web.Service.SilverlightWCF"
                    behaviorConfiguration="SimpleServiceBehavior">
                    <endpoint address="" binding="customBinding"
                    bindingConfiguration="ExampleTeste45.Web.Service.SilverlightWCF.customBinding0"
                    contract="ExampleTeste45.Web.Service.SilverlightWCF" />

                    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
                </service>
            </services>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="SimpleServiceBehavior">
                        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
                multipleSiteBindingsEnabled="true" />-->
        </system.serviceModel>
    </configuration>

我的服务标记:

<%@ ServiceHost Language="C#" Debug="true" Service="ExampleTeste45.Web.Service.SilverlightWCF" CodeBehind="SilverlightWCF.svc.cs" %>

我在谷歌看到的解决方案不起作用,标记中的 Service="ExampleTeste45.Web.Service.SilverlightWCF" 是正确的,端点地址根据定义是空白的,我看到它得到了正确的地址,那又如何我做错了吗?

【问题讨论】:

  • 我也想知道你为什么评论了
  • 它给出了另一个错误,因此发表评论以查看是否解决了问题,并且由于消除了正在显示的错误并构建解决方案没有出现错误,所以我让它保持评论

标签: c# web-services wcf silverlight


【解决方案1】:
<host>
<baseAddresses>
<add baseaddress="http://YourSiteNameORyourhostingmachineName/" /> </baseAddresses>
</host>

到底之前关闭&lt;/service&gt;节点

【讨论】:

  • 请检查以下链接 .. 并告诉我适合您的选项.. 1. forums.asp.net/t/…
  • 已经看过这两个链接,但是对于第二个链接中的正确答案,如果它是我拥有但尝试转换为 Web 的名为 Service 的文件夹,则没有得到他所指的虚拟目录应用程序,但同样的错误仍然显示其余答案不起作用,因为大多数都缺少一些 dll 或部分代码,这不是我的情况(dll:EntityFramework.dll、ExampleTeste45.Web.dll、ExampleTeste45.Web.pdb 和其他一些dll)
  • 我的 bin 的第一个链接位于主机 /SIDAC/bin 的另一个文件夹中,但据说 /SIDAC 是我的根文件夹..
  • 所有解决方案都是stackoverflow.com/questions/720807/… 中给出的解决方案,但他引用的文件夹是服务器中的文件夹,我不明白,所以在完成后它开始工作。
【解决方案2】:

在您的服务元素中,您可能需要将接口添加到合同属性 - contract="ISilverlightWCF"

<service name="ExampleTeste45.Web.Service.SilverlightWCF"
                behaviorConfiguration="SimpleServiceBehavior">
                <endpoint address="" binding="customBinding"
                bindingConfiguration="ExampleTeste45.Web.Service.SilverlightWCF.customBinding0"
                contract="ISilverlightWCF" />

【讨论】:

  • 给出此警告:警告 1 'contract' 属性无效 - 值 'ISilverlightWCF' 根据其数据类型 'serviceContractType' 无效 - 枚举约束失败。并且错误仍然出现没有运气=(
猜你喜欢
  • 1970-01-01
  • 2014-01-08
  • 2013-07-09
  • 1970-01-01
  • 1970-01-01
  • 2021-05-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多