如何在 WCF服务运行之前从web.config 运行IIS ?
答案 0 :(得分:0)
我在程序开头找到了运行IIS服务的解决方案,如下所示:
[STAThread]
static void Main()
{
StartIISService();
Application.Run(new MainForm());
}
private static void StartIISService()
{
ServiceController controller = new ServiceController();
controller.ServiceName = "W3SVC";
controller.MachineName = SystemInformation.ComputerName;
if (controller.Status != ServiceControllerStatus.Running)
controller.Start();
controller.Dispose();
}