{"id":301,"date":"2013-04-11T10:46:41","date_gmt":"2013-04-11T10:46:41","guid":{"rendered":"34ed066df378efacc9b924ec161e7639"},"modified":"2013-04-11T10:46:41","modified_gmt":"2013-04-11T10:46:41","slug":"","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/301","title":{"rendered":"c#\u670d\u52a1\u5b89\u88c5"},"content":{"rendered":"<pre class=\"brush:c#; toolbar: true; auto-links: true;\">\/\/\u8fd0\u884c\u670d\u52a1\r\n           if (args.Length == 0)\r\n            {\r\n                ServiceBase[] ServicesToRun;\r\n                ServicesToRun = new ServiceBase[] \r\n   { \r\n    new Service() \r\n   };\r\n                ServiceBase.Run(ServicesToRun);\r\n            }\r\n            \/\/ \u5b89\u88c5\u670d\u52a1\r\n            else if (args[0].ToLower() == \"\/i\" || args[0].ToLower() == \"-i\")\r\n            {\r\n                try\r\n                {\r\n                    string[] cmdline = { \"\/r\"  };\r\n                    string serviceFileName = System.Reflection.Assembly.GetExecutingAssembly().Location;\r\n                    TransactedInstaller transactedInstaller = new TransactedInstaller();\r\n                    AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline);\r\n                    transactedInstaller.Installers.Add(assemblyInstaller);\r\n                    transactedInstaller.Install(new System.Collections.Hashtable());\r\n                }\r\n                catch (Exception ex)\r\n                {\r\n                    string msg = ex.Message;\r\n                }\r\n            }\r\n            \/\/ \u5220\u9664\u670d\u52a1\r\n            else if (args[0].ToLower() == \"\/u\" || args[0].ToLower() == \"-u\")\r\n            {\r\n                try\r\n                {\r\n                    string[] cmdline = { };\r\n                    string serviceFileName = System.Reflection.Assembly.GetExecutingAssembly().Location;\r\n                    TransactedInstaller transactedInstaller = new TransactedInstaller();\r\n                    AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline);\r\n                    transactedInstaller.Installers.Add(assemblyInstaller);\r\n                    transactedInstaller.Uninstall(null);\r\n                }\r\n                catch (Exception ex)\r\n                {\r\n                    string msg = ex.Message;\r\n                }\r\n            }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;<\/p>\n<pre class=\"brush:c#; toolbar: true; auto-links: true;\"> if (args.Length == 0)\r\n            {\r\n                ServiceBase[] ServicesToRun;\r\n                ServicesToRun = new ServiceBase[] <\/pre>\n<p>&nbsp;<\/p>\n<p> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/301\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[283],"tags":[],"class_list":["post-301","post","type-post","status-publish","format-standard","hentry","category-technologys"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=301"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/301\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}