博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

2009年6月8日

摘要: using System;using System.Threading;using System.Runtime.Remoting.Messaging;namespace 通过委托异步调用方法{ //委托声明(函数签名) delegate string MyMethodDelegate(); class MyClass { //要调用的动态方法 public string MyMethod1() { return "Hello Word1"; } //要调用的静态方法 public static string MyMethod2() { return "Hello 阅读全文

posted @ 2009-06-08 23:30 codingsilence 阅读(124) 评论(0) 推荐(0) 编辑

摘要: using System;using System.Diagnostics;namespace ApplyCmd{ /// /// CmdUtility 的摘要说明。 /// public class CmdUtility { /// /// 执行cmd.exe命令 /// ///命令文本 /// 命令输出文本 public static string ExeCommand(string commandText) { return ExeCommand(new string[] { commandText }); } /// /// 执行多条cmd.exe命令 /// ///命令文本数组 // 阅读全文

posted @ 2009-06-08 22:31 codingsilence 阅读(243) 评论(0) 推荐(0) 编辑

摘要: 一、安装服务:private void InstallService(IDictionary stateSaver, string filepath) { try { System.ServiceProcess.ServiceController service = new System.ServiceProcess.ServiceController("ServiceName"); if(!ServiceIsExisted("ServiceName")) { //Install Service AssemblyInstaller myAssemblyI 阅读全文

posted @ 2009-06-08 22:29 codingsilence 阅读(1850) 评论(0) 推荐(0) 编辑

摘要: 首先先引用System.ServiceProcess.dll然后在引用命名空间using System.ServiceProcess;ServiceController sc = new ServiceController("Server");建立服务对象//服务运行则停止服务 if (sc.Status.Equals(ServiceControllerStatus.Running)) { sc.Stop(); sc.Refresh(); }//服务停止则启动服务 if ((sc.Status.Equals(ServiceControllerStatus.Stopped)) 阅读全文

posted @ 2009-06-08 22:13 codingsilence 阅读(695) 评论(0) 推荐(0) 编辑

摘要: 1:写在前面我们都知道WCF在运行的时候必须自己提供宿主来承载服务。WCF 本身没有附带宿主,而是提供了一个 ServiceHost 的类,该类允许您在自己的应用程序中host WCF 服务。然后调用 ServiceHost 的 Open 方法即可。我们知道WCF是针对SOA的一套技术.对于SOA而言,我们必须确保服务能够正常运行,平稳的运行,所以此时如何host我们的服务,用什么来Host我们的服务是很重要的,所以我们要为我们的应用程序选择一个合适的Host方式是很有必要的.2:常见的几种Host使用Visual Studio.NET可以创建以下几种不同类型的托管应用程序:WinForms 阅读全文

posted @ 2009-06-08 22:03 codingsilence 阅读(232) 评论(0) 推荐(0) 编辑

摘要: 在windows服务中寄宿wcf服务,需要继承ServiceBase,此外,还须要继承Installer以安装服务.以下为具体实现步骤:1.创建文件winservice.cs,输入代码namespace windowswcfservice{ using System.ServiceProcess; using System.ServiceModel; using System.Configuration.Install; using System.Configuration; using System.ComponentModel; [ServiceContract(Namespace=&qu 阅读全文

posted @ 2009-06-08 21:59 codingsilence 阅读(796) 评论(0) 推荐(1) 编辑