我在VB中有一个WCF,它将托管在Windows服务中。我管理安装程序,所以服务实际安装。但是,当我尝试启动该服务时,我收到以下错误:
“本地计算机上的服务已启动然后停止。如果没有工作要做,某些服务会自动停止,例如,性能日志和警报服务。”
Cheking事件查看器给我以下内容:
无法启动服务。 System.InvalidOperationException:找不到与绑定WSHttpBinding的端点的scheme http匹配的基址。注册的基地址方案是[]。 at ... at ... at ...
我猜,这会把我的问题放在这里的某个地方:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<services>
<service name="ExStreamWCF.Service1" behaviorConfiguration="ExStreamWCF.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" contract="ExStreamWCF.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ExStreamWCF.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
然而,作为一个总菜鸟我不知道什么可能是错的。这对我来说真的很新鲜。任何方向都将非常感谢!
谢谢, 杰森
FDSA
答案 0 :(得分:0)
由于您是自托管的,因此您需要为要监听的服务指定一个地址。如果您托管在IIS中,IIS控制地址,但在自托管方案中,您必须在此配置元素中提供地址:
<endpoint address="" binding="wsHttpBinding" contract="ExStreamWCF.IService1">
答案 1 :(得分:0)
将baseaddress添加为:
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost/ExStreamWCF" />
</baseAddresses>
</host>