简体   繁体   中英

Deploying WCF Service Host app?

I have built a solution with 3 projects. A WCF service, a Entity Framework model and a Windows Forms app which hosts the service.

I then have a WPF client app that consumes the service.

In Visual Studio 2013 debugging the service host app works as expected and I can consume the service from the WPF client.

However when I run the host app from the .exe in the debug directory, the service doesn't run. Iget 'Service Started' and no exceptions. I'm running the .exe as Administrator & am logged into the server (Windows Server 2012) as admin on the machine & domain:

 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?

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.

Tricky to debug this across servers, using a trace is probably a good idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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