WP 8 WCF在设备上运行时出错

时间:2014-09-29 15:30:59

标签: c# wcf windows-phone-8

我有一个WP 8应用程序,它使用我的IIS 8中托管的WCF服务。如果我从VS2013运行应用程序并选择设备或模拟器,那么这些应用程序运行正常。如果我部署应用并直接从设备运行应用,则应用会显示错误:

  

对象引用未设置为object.Stack的实例。 tRACE:System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(MessageReply,MessageFault fault,String action,MessageVersion version)...

这是我的WCF服务的app.config:

<services>
  <service behaviorConfiguration="Metadata" name="WCFDataLibrary.EnvioDados">
    <clear />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
      listenUriMode="Explicit">
      <identity>
        <dns value="http://192.168.1.5" />
        <certificateReference storeName="My" storeLocation="LocalMachine"
          x509FindType="FindBySubjectDistinguishedName" />
      </identity>
    </endpoint>
    <endpoint 
      address="http://192.168.1.5/wcfdatasite/EnvioDados.svc" 
      binding="basicHttpBinding"
      contract="WCFDataLibrary.IEnvioDados"/>
    <host>
      <baseAddresses>
        <!--<add baseAddress="http://localhost:8080/WCFDataService" />-->
        <add baseAddress="http://192.168.1.5/WCFDataService/EnvioDados" />
    </baseAddresses>
    </host>
  </service>
</services>

就像我说的,当我从VS2013在设备上运行应用程序时,一切运行良好,但是当我将应用程序部署到同一设备并使用设备的无线网络运行应用程序时,它无效。

1 个答案:

答案 0 :(得分:0)

问题出在serviceMetadata配置中。

原始密钥是:

<serviceMetadata httpGetEnabled="true" httpGetUrl="http://192.168.1.5/WCFDataService/meta"/>

,正确的值必须是:

<serviceMetadata httpGetEnabled="true" httpGetUrl="http://192.168.1.5/WCFDataService/meta?wsdl" />

现在它完美无缺!

相关问题