1
喜一有WCF服務libary此配置:WCF Windows服務,服務元數據可能無法訪問
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="Default" name="ComDocs.ControlServerServiceLibary.Concrete.TokenService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/TokenService" />
</baseAddresses>
</host>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="basic" binding="basicHttpBinding" contract="ComDocs.ControlServerServiceLibary.Abstract.ITokenService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
如果我在調試構建它,一切都運行在本地主機上的罰款。但是,如果我做一個Windows服務庫使用相同的配置:
public partial class TokenService : ServiceBase
{
ServiceHost _host = null;
public TokenService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
Trace.WriteLine("Starting Token Service...");
_host = new ServiceHost(typeof(TokenService));
_host.Open();
}
protected override void OnStop()
{
Trace.WriteLine("Shutting down Token Service...");
if (_host != null)
{
_host.Close();
_host = null;
}
}
}
與InstallUtil安裝並啓動它:
但錯誤:
您是否已將上述配置複製到服務的app.config中? – 2011-06-17 09:15:41
@ Richard-Blewett是的,我將app.config從服務庫文件複製到windows服務項目中 – 2011-06-17 09:54:36
由於您更改了正在監聽的進程,防火牆可能會阻止端口8080的請求? – 2011-06-17 10:08:02