net.tcpを使用して単一のWindowsサービスでホストしようとしている2つのサービスを持つWCFアプリケーションがあります。どちらのサービスも問題なく実行できますが、両方をWindowsサービスに入れようとすると、最初のサービスだけが読み込まれます。2番目のサービスコンストラクターが呼び出されていると判断しましたが、OnStartは起動しません。これは、WCFが2番目のサービスの読み込みで問題を検出していることを示しています。
net.tcpを使用して、ポート共有をオンにし、サーバーでポート共有サービスを開始する必要があることを知っています。これはすべて正常に機能しているようです。さまざまなtcpポートにサービスを配置しようとしましたが、それでも成功しません。
私のサービスインストーラークラスは次のようになります。
[RunInstaller(true)]
public class ProjectInstaller : Installer
{
private ServiceProcessInstaller _process;
private ServiceInstaller _serviceAdmin;
private ServiceInstaller _servicePrint;
public ProjectInstaller()
{
_process = new ServiceProcessInstaller();
_process.Account = ServiceAccount.LocalSystem;
_servicePrint = new ServiceInstaller();
_servicePrint.ServiceName = "PrintingService";
_servicePrint.StartType = ServiceStartMode.Automatic;
_serviceAdmin = new ServiceInstaller();
_serviceAdmin.ServiceName = "PrintingAdminService";
_serviceAdmin.StartType = ServiceStartMode.Automatic;
Installers.AddRange(new Installer[] { _process, _servicePrint, _serviceAdmin });
}
}
両方のサービスは非常によく似ています
class PrintService : ServiceBase
{
public ServiceHost _host = null;
public PrintService()
{
ServiceName = "PCTSPrintingService";
CanStop = true;
AutoLog = true;
}
protected override void OnStart(string[] args)
{
if (_host != null) _host.Close();
_host = new ServiceHost(typeof(Printing.ServiceImplementation.PrintingService));
_host.Faulted += host_Faulted;
_host.Open();
}
}