简体   繁体   English

部署WCF服务主机应用程序?

[英]Deploying WCF Service Host app?

I have built a solution with 3 projects. 我用3个项目构建了一个解决方案。 A WCF service, a Entity Framework model and a Windows Forms app which hosts the service. WCF服务,实体框架模型和承载该服务的Windows Forms应用程序。

I then have a WPF client app that consumes the service. 然后,我有一个使用该服务的WPF客户端应用程序。

In Visual Studio 2013 debugging the service host app works as expected and I can consume the service from the WPF client. 在Visual Studio 2013调试中,服务主机应用程序将按预期工作,并且我可以从WPF客户端使用服务。

However when I run the host app from the .exe in the debug directory, the service doesn't run. 但是,当我从调试目录中的.exe运行主机应用程序时,该服务无法运行。 Iget 'Service Started' and no exceptions. Iget“服务已启动”,没有例外。 I'm running the .exe as Administrator & am logged into the server (Windows Server 2012) as admin on the machine & domain: 我以管理员身份运行.exe并以管理员身份在计算机和域上登录到服务器(Windows Server 2012):

 public partial class RegimesHost : Form
{
    public RegimesHost()
    {
        InitializeComponent();
        lblStatus.Text = string.Empty;
    }

    ServiceHost host;
    private void btnStart_Click(object sender, EventArgs e)
    {
        host = new ServiceHost(typeof(RegimesService));
        host.Open();
        lblStatus.Text = "Started...";
    }

    private void btnStop_Click(object sender, EventArgs e)
    {
        host.Close();
        lblStatus.Text = "Stopped...";
    }     
}

Is there something obvious I'm missing here as to why the service will run inside of Visual Studio's debug but not from the .exe in the debug directory? 关于该服务为什么要在Visual Studio的调试中运行而不是在调试目录中的.exe中运行,我是否有明显的遗漏?

Finally got the service running. 终于使服务运行了。

I had to use the next port in the Add Service Reference wizard on the client side. 我必须在客户端的“添加服务参考”向导中使用下一个端口。 Presumably this is because de-bug mode uses the port defined in the app.config therefore when you run the application stand alone, that port is already designated to the debug runtime and therefore the app takes the next port along. 大概是因为调试模式使用了app.config中定义的端口,因此当您独立运行应用程序时,该端口已指定给调试运行时,因此应用程序将使用下一个端口。

Tricky to debug this across servers, using a trace is probably a good idea. 棘手的跨服务器调试此技巧,使用跟踪可能是一个好主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM