私は C# や .NET の専門家ではありません。でも使わなきゃいけない…
InstallUtil.exe MyService.exe
基本的に WCF サービスを実行している Windows サービスをインストールするために実行しています。私は WFC インターフェイスを定義し、それを実装しました。以下はインターフェースです。
[ServiceContract(Namespace = "http://WCFService", Name = "WCFService")]
public interface IWCFService
{
[OperationContract]
User Login(string userName, string password);
[OperationContract]
List<Project> GetProjects(Guid userGuid);
[OperationContract]
List<Stylesheet> GetStylesheets(Guid projectGuid);
}
また、次のように Windows サービスを定義しました。
public partial class Service: ServiceBase
{
public FlatWsdlServiceHost m_fwsh = null; // extends ServiceHost
public DesignerService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
this.EventLog.WriteEntry("OnStart Successfull", EventLogEntryType.Information);
if (m_fwsh != null)
{
m_fwsh.Close();
}
// Create a ServiceHost for the EventWebService type and
// provide the base address.
Uri localUri= new Uri("http://localhost:7777/");
m_fwsh = new FlatWsdlServiceHost(typeof(WCFService), localUri);
// Open the ServiceHostBase to create listeners and start
// listening for messages.
m_fwsh.Open();
}
protected override void OnStop()
{
//base.OnStop();
if (m_fwsh != null)
{
m_fwsh.Close();
m_fwsh = null;
}
}
protected override void OnPause()
{
base.OnPause();
}
}
InstallUtil.exe MyService.exe
ログを実行すると、次のように表示されます。
Installing assembly 'MyService.exe'.
Affected parameters are:
logtoconsole =
logfile = MyService.InstallLog
assemblypath = MyService.exe
No public installers with the RunInstallerAttribute.Yes attribute could be found in the MyService.exe assembly.
Committing assembly 'MyService.exe'.
Affected parameters are:
logtoconsole =
logfile = MyService.InstallLog
assemblypath = MyService.exe
No public installers with the RunInstallerAttribute.Yes attribute could be found in the MyService.exe assembly.
Remove InstallState file because there are no installers.
また、serviceInstaller1 と serviceProcessInstaller1 を初期化する ProjectInstaller.cs もあります。WCF サービスを追加する前は、Windows サービスは正常にインストールされ、「OnStart Successful」メッセージが Windows ログに書き込まれていました。
どんな助けや提案も大歓迎です。