生命周期
2015-11-09 12:08
281 查看
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Runtime.Remoting; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; namespace System.Web.Hosting { [SecurityPermission(SecurityAction.LinkDemand, Unrestricted = true)] public sealed class AppManagerAppDomainFactory : IAppManagerAppDomainFactory { // Fields //定义ApplicationManager private ApplicationManager _appManager; // Methods public AppManagerAppDomainFactory() { this._appManager = ApplicationManager.GetApplicationManager(); this._appManager.Open(); } internal static string ConstructSimpleAppName(string virtPath) { if (virtPath.Length <= 1) { return "root"; } return virtPath.Substring(1).ToLower(CultureInfo.InvariantCulture).Replace('/', '_'); } [return: MarshalAs(UnmanagedType.Interface)] public object Create(string appId, string appPath) { object obj2; try { if (appPath[0] == '.') { FileInfo info = new FileInfo(appPath); appPath = info.FullName; } if (!StringUtil.StringEndsWith(appPath, '\\')) { appPath = appPath + @"\"; } ISAPIApplicationHost appHost = new ISAPIApplicationHost(appId, appPath, false); ISAPIRuntime o = (ISAPIRuntime)this._appManager.CreateObjectInternal(appId, typeof(ISAPIRuntime), appHost, false, null); o.StartProcessing(); obj2 = new ObjectHandle(o); } catch (Exception) { throw; } return obj2; } public void Stop() { this._appManager.Close(); } } }
View Code
AppManagerAppDomainFactory中的构造函数已经写出来了,同样也实现了create和stop方法
相关文章推荐
- 配置使用EF6.0常见的一些问题及解决方案
- Android动画学习(二)——Tween Animation
- Delphi 解压缩 ZipForge
- 机器学习实战-第二章
- 关于css控制中文的一些技巧
- jsp实现防盗链的方法
- Monkey之Log分析
- iOS [UIScreen mainScreen].scale
- 在Webstorm中使用Autoprefixer
- poj2632模拟法
- sqlserver日期(时间)格式化
- WEB前端学习 Day 6(Javascript 初识+变量+逻辑判断+数据类型)
- 快排,堆排序,折半查找算法(Java版)
- ubuntu14.04安装360随身wifi 2代
- cms修改后台目录
- 《How Tomcat Works》学习笔记(一)
- html小白冷知识搜集
- <context:component-scan/>
- cms
- sp&wp 的三板斧