WCF does not host
本文关键字:host not does WCF | 更新日期: 2023-09-27 18:29:27
直截了当地说,我有一个WCF项目和Host项目(我想启动Service),当我将WCF作为启动项目时,它会托管服务,我会收到一条确认消息(右下角),一切都很好,但当我尝试从Host项目托管时,它不会托管,也没有任何确认消息。
这是我的主机代码:
static void Main(string[] args)
{
using (ServiceHost host = new ServiceHost(typeof(MovieService)))
{
host.Open();
Console.WriteLine("The host is online.");
Console.ReadLine();
host.Close();
}
}
主机app.config:
<system.serviceModel>
<services>
<service name="CinemaProject.WCF.MovieService">
<endpoint address="" binding="wsHttpBinding" contract="CinemaProject.WCF.IMovieService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/CinemaProject.WCF/MovieService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我的WCF代码:
public class MovieService : IMovieService
{
static MovieCtr movieCtr = new MovieCtr();
public void Add(Movie movie)
{
movieCtr.add(movie);
}
public void SearchById(int id)
{
}
public void Update(Movie movie)
{
}
public void Delete(Movie movie)
{
}
public void DeleteById(int id)
{
}
public IEnumerable<MovieDTO> All()
{
return movieCtr.All();
}
}
和WCF app.config:
<system.serviceModel>
<services>
<service name="CinemaProject.WCF.MovieService">
<endpoint address="" binding="wsHttpBinding" contract="CinemaProject.WCF.IMovieService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/CinemaProject.WCF/MovieService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
有人能看看它,给我指明正确的方向,如果可能的话,也发布一个解决方案吗。
谢谢,Marius J.
尝试从CMD窗口运行此程序:
netsh http add urlacl url=http://+8733:/ user=DOMAIN'user
指定正确的域和用户