using log4net.Config; using System; using System.IO; using System.Reflection; using System.ServiceProcess; namespace PluginListener { public class Program { /// /// 应用程序的主入口点。 /// [STAThread] public static void Main() { string assemblyFilePath = Assembly.GetExecutingAssembly().Location; string assemblyDirPath = Path.GetDirectoryName(assemblyFilePath); string configFilePath = Path.Combine(assemblyDirPath,"log4net.config"); XmlConfigurator.Configure(new FileInfo(configFilePath)); ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Listener() }; ServiceBase.Run(ServicesToRun); } } } // sc create "SolidWorks Listener" binpath= "D:\Workspace\PdmSwPlugin2\PdmSw\bin\x64\Debug\Listener\PluginListener.exe" type= interact type= own displayname= "SolidWorks Listener"