人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

September 21, 2006

Code Smith应用

Filed under: 开发工具

Code Smith应用
在我们的project中,对于一个web service要进行3个地方的处理
1.asmx file,比如GCRecommendWebSiteManagementService.asmx.vb, 提供web methods
<System.Web.Services.WebService(Namespace:=”http://tempuri.org/“)> _
Public Class GCRecommendWebSiteManagementService
Inherits BaseService

<WebMethod(), System.Web.Services.Protocols.SoapHeader(”TokenValue”)> _
Public Function GetAllRecommendWebSite() As DataSet
end Function
end Class

2.内部逻辑class, 比如GCRecommendWebSiteManagementControl.vb
Public Class GCRecommendWebSiteManagementControl
Inherits BaseControl
Public Function GetAllRecommendWebSite() As DataSet

End Function
end class

3.在Client 端提供proxy 比如GCRecommendWebSiteManagementServiceProxy.vb
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute(”code”), _
System.Web.Services.WebServiceBindingAttribute(Name:=”GCRecommendWebSiteManagementServiceSoap”, [Namespace]:=”http://tempuri.org/“)> _
Public Class GCRecommendWebSiteManagementServiceProxy
Inherits BaseProxy
<System.Web.Services.Protocols.SoapHeaderAttribute(”TokenValue”), _
System.Web.Services.Protocols.SoapDocumentMethodAttribute(”http://tempuri.org/GetAllRecommendWebSite“, RequestNamespace:=”http://tempuri.org/“, ResponseNamespace:=”http://tempuri.org/“, Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Public Function GetAllRecommendWebSite() As System.Data.DataSet
Dim results() As Object = Me.Invoke(”GetAllRecommendWebSite”, New Object(-1) {})
Return CType(results(0), System.Data.DataSet)
End Function

Public Function BeginGetAllRecommendWebSite(ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
Return Me.BeginInvoke(”GetAllRecommendWebSite”, New Object(-1) {}, callback, asyncState)
End Function

Public Function EndGetAllRecommendWebSite(ByVal asyncResult As System.IAsyncResult) As System.Data.DataSet
Dim results() As Object = Me.EndInvoke(asyncResult)
Return CType(results(0), System.Data.DataSet)
End Function
end Class

三部分代码大同小异,目前的做法是copy-post-modify,不好.
我想可以通过下面的方法来自动生成代码:
1. 在GCRecommendWebSiteManagementControl.vb中定义出一个web service所有方法的原型.
2. 在CodeSmith 模板文件执行时利用CodeDomProvider.CompileAssemblyFromSource动态build这个文件,
生成一个assembly,再遍历这个assemlby中的type,type中的method, 利用code dom 就可以生成对应的代码.

注意由于vb会在build一个assembly时加入诸如My.MyApplication,My.MyComputer的class,同时一个
class也会从object继承一些method,所以又需要定义一个attribut来标识需要生成代码的type和
method.

收获
1.使用了自定义的assembly(包含标识type和method的attribute)
2.使用子模板,根据不同的语言生成代码.
3.使用code behind文件,把大量的逻辑放在.cs文件中
4.复习了codedom,
VBCodeProvider.CreateGenerator 已被废弃,现在的用法是:
CodeDomProvider codeProvider = CodeDomProvider.CreateProvider(”VisualBasic”);
codeProvider.GenerateCodeFromMember(cmm, sw, new CodeGeneratorOptions());
5.CodeDom动态编译

September 19, 2006

vs2005快捷键收集

Filed under: Visual Studio

//——-Coding
Ctrl+K, Ctrl+M
Surroun Ctrl+K, Ctrl+S
Code snippet Ctrl+K, Ctrl+X

注释 Ctrl+K, Ctrl+C
remove注释 Ctrl+K, Ctrl+U
Clipboard内容循环 Ctrl+Shift+V

删除当前行 Ctrl+Shift+L

自动换行 Ctrl+E, Ctrol+W

大小写 Ctrl+Shift+U, Ctrl+U

Navigation backward Ctrl+-
Navigation forward Ctrl+Shift+-
//——-Refactor
Rename Ctrl+R, Ctrl+R

//——-Search
渐进式搜索 Ctrl+I
反向渐进式搜索 Ctrl+Shift+I

//——-各种窗口
Command window Ctrl+Alt+A
Show breakpoints window Ctrl+Alt+B
Solution explore Ctrl+Alt+L
Code Definition window Ctrl+\, Ctrl+D

Exceptions Ctrl+Alt+E
Attach to Process Ctrl+Alt+P
Task List Ctrl+\,Ctrl+T
Error List Ctrl+\,Ctrl+E
Toolbox Ctrl+Alt+T
Class Ctrl+Shift+C

Macro Explore Alt+F8

//——-Bookmark
Bookmark window Ctrl+K, Ctrl+W
Toogle Bookmark Ctrl+K, Ctrl+K
Next Bookmark Ctrl+K, Ctrl+N
Previous Bookmark Ctrl+K, Ctrl+P
Clear Bookmarks Ctrl+K, Ctrl+L
Add Task List Ctrl+K, Ctrl+H
Remove Task List Ctrl+K, Ctrl+H

//——-Format
Format Ctrl+K, Ctrl+D

//——-Breakpoint
New breakpoint Ctrl+D
Clear all breakpoints Ctrl+Shift+F9

//——-VS
全屏 Shift+Alt+Enter
切换active file Ctrl+Tab
Open file Ctrl+O
New file Ctrl+N
New project Ctrl+Shift+N

September 15, 2006

STAThreadAttribute

Filed under: .NET

在VS中,生成一个windows application,程序的Main()函数上会应用
STAThreadAttribut, 而生成Console application就不会应用这个Attribute

static class Program
{
[STAThread]
static void Main()
{

Application.Run(new Form1());
}
}

class Program
{
static void Main(string[] args)
{
}
}

缺省情况下,application的主线程的Apartment state为multi-threaded apartment
(ApartmentState.MTA),设置主线程Apartment state的唯一方法就是使用STAThreadAttribut.

STAThreadAttribut使得一个application的COM 线程模式为single-threaded apartment (STA),
STAThreadAttribut只能应用在程序的入口函数上,对于其他的函数不起作用,

在程序中设置一个线程的COM 线程模式,也可以使用如下的代码:

Thread t = new Thread(new ThreadStart(StartNewStaThread));
//.net1.1
t.ApartmentState = ApartmentState.STA;
t.Start();

private void StartNewStaThread()
{
Application.Run(new Form1());
}
在.net2.0中Thread.ApartmentState被Thread.SetApartmentState (ApartmentState state)取代

注意线程的Apartment state 必须要在线程启动前设置.

从逻辑上说,apartment 是线程和object的容器,apartment中的object可以被这个apartment中任何
一个线程访问. 一个STA只能包含一个线程,一个MTA可以包含多个线程。MTA中各线程可以并行的调用
本公寓内实例化的组件一个进程可以包含多个STA,但只能有一个MTA。

.NET framework不使用apartment 模式, 所有的managed object在使用共享资源时自发地保证线程
安全.由于COM使用了apartment,所以CLR在操作COM ojbect时需要生成和初始化apartment.常用的COM组件有
Clipboar和File Dialog.COM 线程模型只适用于使用 COM interop 的应用程序。如果将此属性应用到
不使用 COM interop 的应用程序,将没有任何效果。
Windows Forms不支持MTA.所以windows程序要使用STAThreadAttribut

在Fantasy Soft的bolg不可错过的MSDN TV-IronPython: Python on the .NET Framework,有
下列描述:
如果你打算在Interactive Mode下面直接执行以上代码,你会碰到如下的错误:
Traceback (most recent call last):
at <shell>
System.InvalidCastException: Creating an instance of the COM component with CLSID {D45FD2FC-5C6E-11D1-9EC1-00C04FD7081F}
from the IClassFactory failed due to the following error: 80004002.
这是由线程的问题引起的,解决的办法就是修改IronPythonConsole目录下PythonCommandLine.cs,在源代码的Main函数前增加[STAThread],
然后重新构建这个Solution。

MSDN上对80004002的定义是: Interface not supported error
见:Standard COM Errors
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CS07Default/html/b88924d0-f9ca-41a5-af9e-66158ab795d2.asp

September 14, 2006

IronPython Python on the .NET Framework笔记

Filed under: .NET

见IronPython: Python on the .NET Framework
http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20051110PythonJH/manifest.xml
————————————-
Build IronPython
————————————-
msbuild IronPython.sln
若在vs中build,请把 IronPythonConsole设为startup project.

————————————-
构成
————————————-
ipy.exe IronPython的控制台
ipyw.exe
Iron.Math.dll
Iron.Python.dll
Lib\Site.py

————————————-
IronPython 用到了.net2.0 哪些 Feature?
————————————-
These include Generics, DynamicMethods, new kinds of delegates, and more.

————————————-
Demo中feature的学习
————————————-
1.import Python 库

>>> import sys # 导入sys module;
>>> sys.path.append(”c:/Python24/Lib”) # 增加搜索路径
>>> import this # 导入Python中名为this的module;
>>> import random # 导入Python中名为random的module;
>>> random.__doc__ # 打印模块的document;
>>> cards = range(51) # range方法用于产生51个元素的List
>>> random.shuffle(cards) # 洗牌
>>> cards # 打印洗牌结果

2. 使用.net 类库

>>> import System # import the standard system module
>>> System.Environment.Version # 打印syste version
>>> form System.Math import * # import all the functions from the math module
>>> Sin(PI/2)
>>> form System import Random
>>> r = Random() # Create new instance
>>> [r.Next(0, 100) for i in range(10)] # 生成10个随机数

3. 派生
>>> class MyRandom(Random): pass # pass表示一条空语句
>>> mr = new MyRandow()
>>> [mr.Next(0, 100) for i in range(10)]
>>> mr.foo = 42 # 为实例mr增加了一个名为foo的field
>>> def Sample(self): return 0.5 # 定义了一个名为Sample的function
>>> MyRandom.Sample = Sample # Override Random 的Sample方法
>>> [mr.Next(0,100) for i in range(10)] # 此时由于改写了Sample方法,而Next方法需要依靠Sample方法的返回结果,
# 因此得到值全为50
>>> def Sample(self): return 0.8 + 0.2*super(MyRandom, self).Sample() # 重新定义了Sample function,调用基类方法

4. 使用From,为control定义event handler
>>> from AvalonStartup import *
>>> w = Window()
>>> w.Show()
>>> b = Button(Content=”Click me”)
>>> w.Content = b
>>> def doIt(* args ): print args
>>> b.Click += doIt

4. 使用 XAML
>>> calc = LoadXaml(’calc.xaml’)
>>> w.Content = calc
>>> for node in Walk(calc) : print node

>>> [node for node in Walk(calc) if isinstance(node, Button)] # 判断一个instance 的type
>>> buttons = _
>>> for b in buttons : print b
>>> for b in buttons : b.Background = Brushes.Blue
>>> ss = SpeakchSynthesizer()
>>> def sayIt(b , e) : ss.SpeakTextAsync(b.Name)
>>> for b in buttons : b.Click += sayIt

5. 与C#调用PythonEngine, 在vs中debug .py调本
在xaml文件中写
<Button Content=”Run Script” Click =”RunScript”>

在cs文件中
using IronPython.Hosting;
public void RunScript(object a , object b)
{
PythonEngine engine = new PythonEngine();
engine.SetVariable(”win” , this);
engine.Execute(”win.SetImage(’c:/images/itrun.jpg’)”);

System.Windows.Forms.OpFileDialog ofd = new System.Windows.Forms.OpFileDialog();
ofd.ShowDialog();
eng.RunFile(ofd.FileName); # 执行文件simple.py
}

# simple.py
text = TextBlock(Text=”Hello”, FontSize=100, Forground=Brush.White)
a = DoubleAnination(0.0 , Duration(TimeSpan.FromSeconds(3)))
a.RepeatBehavior = RepeatBehavior(3)
text.BeginAnimation(Shape.OpacityProperty , a)
Canvas.SetLeft(text , 50)
Canvas.SetTop(text , 10)
win.Content.Children[1].Children.Add(text)

由于IronPython代码最终是会转换为IL代码,由.NET Framework运行,故而IronPyton实现了以下功能:

在c#中调用一个.py文件,如果文件中出错,vs可以brack到出错的代码,
.net debugger可以可以在.py文件中加断点,
可以在debug时修改.py中变量的值

6. 在.py脚本中调用COM组件
首先使用.tlbimp生成将COM组件的wrapper
>tlbimp c:\WINDOWS\msagent\agentsvr.exe
生成AgentServerOjbects.dll

# merlin.py
import sys
sys.LoadAssemblyFromFile(AgentServerObjects.dll)
from AgentServerOjbects import *
a = AgentServerClass
id, rast = a.Load(”merlin.acs”)
ch = a.GetCharacter(id)
ch.SetSize(128,128)
ch.Show(0)
ch.MoveTo(600,100,2000)

我使用的是IronPython1.0, 在1.0中,去掉了LoadAssemblyByName和LoadAssemblyFromFile这两个方法.
而使用built-in module:clr来提供Loading .NET libraries的功能:
clr.AddReference
clr.AddReferenceToFile
clr.AddReferenceToFileAndPath
clr.AddReferenceByName
clr.AddReferenceByPartialName

代码修要改为
# merlin.py for IronPython 1.0
import clr
clr.AddReferenceToFileAndPath(’c:\IronPython\AgentServerObjects.dll’)
from AgentServerObjects import *
a = AgentServerClass()
id, rast = a.Load(”merlin.acs”)
ch = a.GetCharacter(id)
ch.SetSize(128,128)
ch.Show(0)
ch.MoveTo(600,100,2000)

September 12, 2006

IIS 7.0 RC1的新feature

Filed under: ASP.NET

原文见.
http://weblogs.asp.net/scottgu/archive/2006/09/07/IIS-7.0-RC1.aspx

1.可以create多个web site(IIS6也可以啊?)
2.IIS 管理和 asp.net管理被放在一起
3.IIS 使用和asp.net类似的web.conifg,发布时不再需要使用admin script去设置IIS
4.IIS 管理工具提供了”delegated administration”,可用于远程管理.
5.IIS 管理工具的UI可扩展,从而可以管理自己写的HTTP runtime modules.
6.IIS 管理工具集成了ASP.NET 2.0 Membership 管理
7.IIS 5 中在一个web site下只能create Virtual Directory,
IIS 6 中在一个web site下可以create website 或 Virtual Directory,
可设置一个VD的Application Setting,如果设置了Application Setting,VD的图标会变化.
在IIS 7 中,明确区分了Application和VD,在web site的context menu 上有两个选项:
create vd 和 create application.

September 8, 2006

防止IIS out of memory

Filed under: ASP.NET

有关System.OutOfMemoryException,google一下,会找到很多究其本质,System.OutOfMemoryException出现有两种可能:
1.在我们试图新建一个对象时,而CLR又找不到任何可用内存,GC也找不到可释放的对象时被抛出,应用程序此时可捕获该异常.
2.CLR需要内存时,而却系统却不能提供,也会抛出该异常,此时,应用程序不能捕获该异常.

思路:给CLR更多的内存.减少应用程序所占的内存,及时释放无用的对象.对于ASP.NET程序,
CLR host在 asp.net的工作进程中,问题就转化为如何让asp.net的工作进程有更多的用户
地址空间.同时要设法利用IIS的一些功能来回收工作进程占用的内存.

————————————————————————————–
1. Enabling 4GT RAM Tuning
————————————————————————————–
此配置只在Windows 2000 Advanced Server,Data Center及Windows Server 2003以上才支持.
该模型可提供 3GB 的用户地址空间,另 1GB 保留给内核,通过在 boot.ini 中添加 /3GB 选项来启用该模型。

注意:Windows Server 2003 上支持的最大内存为 4 GB。但是,Windows Server 2003 Enterprise Edition
支持 32 GB 的物理 RAM。使用物理地址扩展 (PAE) 功能,Windows Server 2003 Datacenter Edition 可支持
64 GB 的物理内存。
对于下列系统,可以在 Boot.ini 文件中使用 3 GB 开关:
Microsoft Windows Server 2003 Standard Edition, but only in non-production environments.
Microsoft Windows Server 2003 Enterprise Edition 或
Microsoft Windows Server 2003 Datacenter Edition。

在WindowsXP和Windows Server 2003中提供一个新的启动参数/USERVA,必须和/3GB参数联合使用,
比如: 3GB /USERVA=2500 的意思就是配置2.5G的内存地址空间预留给用户内存空间,1.5G的留给核心
内存空间.


What Is 4GT?
http://technet2.microsoft.com/WindowsServer/en/library/cab49770-0239-4a8b-90c1-612e70b729c81033.mspx

How 4GT Works
http://technet2.microsoft.com/WindowsServer/en/library/edc9f27d-76fb-4139-9555-20acc684c3af1033.mspx

You may receive the “System.OutOfMemoryException” error message when you view ASP.NET pages on a server that has 3 gigabytes of RAM
http://support.microsoft.com/default.aspx?scid=kb;en-us;820108

如何配置 SQL Server 以便使用 2 GB 以上的物理内存
http://support.microsoft.com/default.aspx?scid=kb;zh-cn;274750

结论: 此选项可以使CLR有更多的可分配内存,我们使用的是windows 2003标准版,不推荐用这个参数.

————————————————————————————–
2. 设置.NET machine.config file的<processModel>或配置IIS,及时释放工作进程.
————————————————————————————–
<processModel>中有的一些配置:

memoryLimit(default=60),指定了ASP.NET进程(IIS5中为aspnet_wp,IIS6中为w3wp)
能够使用所有物理内存的百分比。当超过这个限额时,IIS回收工作进程,并创建一个新
的进程去负责应付Http请求。
*注意,如果将session存放在进程中,session会丢失.

当我们有很大内存时,memoryLimit这个值是需要进行适当的调整的。比如一台4G内存的服务器,
那么4G*60%=2.4G。但是,对于Win32操作系统,一个进程所能占用的所有内存空间只有2G。
当ASP.NET进程占用的内存开始达到2G时,由于它并没有达到2.4G的”回收阈值”,所以IIS不会
启动recycle进程操作,但是由于Win32的限制,实际上已经不能给这个进程分配更多的内存了,
于是,OutOfMemoryException就很可能会被抛出了。为了避免这样的情况,我们就必须将”memoryLimit”
适当调小,以让IIS更早的进行进程回收。

微软推荐的ASP.NET进程占用内存是不超过60%物理内存,当使用2GB地址空间时最好使计算出的实
际值不超过800M。

!注意缺省情况下IIS6并不设置内存的使用限制.


Running ASP.NET 1.1 with IIS 6.0
http://www.asp.net/faq/AspNetAndIIS6.aspx#2(非常重要!!)

ASP.NET Performance Monitoring, and When to Alert Administrators
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/monitor_perf.asp

Timeout(default=Infinite),持续运行了timeout指定的时间后,重启 ASP.NET服务

IdleTimeout(default=Infinite),在 idleTimeout 指定的时间内没人的访问,重启 ASP.NET服务

PingTimeout(default =5s),ISAPI extension 会每隔一段时间(PingFrequency, default=30)ping一次
工作进程,如果5秒内无相应,则重启工作进程.

PingFrequency(default =30s)

RequestLimit(default=Infinite),在处理了n个请求后重启工作进程.

这些配置在IIS6中不再由machine.config控制,而是由IIS控制.

如果使用iis5及以下版本需要安装MS提供的IIS5Recycle service
安装说明见http://support.microsoft.com/?id=322350

3. 编程
System.Drawing注意调用dispose
慎用new byte[],最好定义一个比较小的byte数组做为缓存,然后循环使用。

参照
OutOfMemoryException问题的处理
http://www.cnblogs.com/chainet/archive/2005/01/25/97000.html

ASP.NET中的OutOfMemoryException
http://blog.joycode.com/kaneboy/archive/2005/05/07/50409.aspx

Tuning .NET Application Performance
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt17.asp

IIS 6.0 Tuning for Performance
http://www.eggheadcafe.com/articles/20050613.asp

FIX: SetMinThreads and GetMinThreads API Added to Common Language Runtime ThreadPool Class
http://support.microsoft.com/default.aspx?scid=kb;en-us;810259

September 5, 2006

.NET2.0上的MCPD 考试

Filed under: 技术

如何成为MCPD
方案1:
MCTS+
Exam 70-549: PRO: Designing and Developing Enterprise Applications by Using the Microsoft .NET Framework

方案2:
MCSD+升级考试(70-553,70-554)
这两个考试含盖了MCTS的所有内容和70-549的内容,MCTS的教材一个也不能落下.

MCTS考试:
Exam 70-536: TS: Microsoft .NET Framework 2.0 - Application Development Foundation
Exam 70-526: TS: Microsoft .NET Framework 2.0 - Windows-Based Client Development
Exam 70-528: TS: Microsoft .NET Framework 2.0 - Web-Based Client Development
Exam 70-529: TS: Microsoft .NET Framework 2.0 - Distributed Application Development

Book list:
MCTS Self-Paced Training Kit (Exam 70-526): Microsoft .Net Framework 2.0 Windows-Based Client Development (available late 2006)
MCTS Self-Paced Training Kit (Exam 70-528): Microsoft .NET Framework 2.0 Web-Based Client Development
MCTS Self-Paced Training Kit (Exam 70-529): Microsoft .NET Framework 2.0 Distributed Application Development
<*>MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0-Application Development Foundation
MCPD Self-Paced Training Kit (Exam 70-547): Designing and Developing Web-Based Applications Using the Microsoft .NET Framework (available late 2006)
MCPD Self-Paced Training Kit (Exam 70-548): Designing and Developing Windows-Based Applications Using the Microsoft .NET Framework (available late 2006)
MCPD Self-Paced Training Kit (Exam 70-549): Designing and Developing Enterprise Applications Using the Microsoft .NET Framework (available late 2006)

<*>CLR via C#: Applied Microsoft .NET Framework Programming, second edition
Debugging, Testing, and Tuning Microsoft .NET 2.0 Applications
Programming Microsoft Visual C# 2005: The Language
Programming Microsoft ADO.NET 2.0 Core Reference
Programming Microsoft ASP.NET 2.0 Applications: Advanced Topics

Sql现在有两个的MCTS:SQL Server 2005和SQL Server 2005 Business Intelligence
考试为:Exam 70-431: TS: Microsoft SQL Server 2005 - Implementation and Maintenance
和Exam 70-445: Microsoft SQL Server 2005 Business Intelligence - Implementation and Maintenance (available early 2007)

Book list:
MCTS Self-Paced Training Kit (Exam 70-431): Implementing and Maintaining Microsoft SQL Server 2005 (available mid-2006)
Microsoft SQL Server 2005: Applied Techniques Step by Step
Inside Microsoft SQL Server 2005: The Storage Engine
Programming Microsoft SQL Server 2005 (available mid-2006)
Microsoft SQL Server 2005 Administrator’s Pocket Consultant
Microsoft SQL Server 2005 Administrator’s Companion (available mid-2006)
———————————————————————————–
Microsoft SQL Server 2005 Analysis Services Step by Step
Microsoft SQL Server 2005 Reporting Services Step by Step
Microsoft SQL Server 2005: Database Essentials Step by Step
Microsoft SQL Server 2005: Applied Techniques Step by Step
Inside Microsoft SQL Server 2005: The Storage Engine
Inside Microsoft SQL Server 2005: T-SQL Querying
Inside Microsoft SQL Server 2005: Query Tuning and Optimization (available 2007)
Programming Microsoft SQL Server 2005

MCTS的信息见Microsoft Certified Technology Specialist (MCTS)
http://www.microsoft.com/learning/mcp/mcts/default.mspx

每门考试所需的书籍见
Microsoft Certified Professional Developer (MCPD)
http://www.microsoft.com/learning/mcp/mcpd/

MS的WPF站点

Filed under: Windows platform

http://wpf.netfx3.com/

September 4, 2006

IIS

Filed under: ASP.NET

跟我一起学Visual Studio 2005(12):IIS 5.1_6.0 内幕

UNIX CGI使用一种进程外(out-of-process)执行模型.每次请求都要打开一个进程,
故MS的ISAPI选择了进程内模型(IIS4之前),
所有的操作都基于进程(inetinfo.exe)内执行,缺点在于:
更新程序必须重启IIS
一个程序出错,IIS崩溃
*asp出现于IIS3,asp.dll是ISAPI的扩展实现.

——–IIS4
增加了进程隔离(process isolation),注意这里的隔离以应用程序为单位,和UNIX CGI不同.

进程隔离的缺点
- 进程外应用程序的运行速度可能比进程内应用程序慢很多
- 所有的配置被加载到inteinfo.exe进程空间中.进程外应用程序不能
使用内置的IIS管理对象来访问IIS配置数据库属性.
- 进程外应用程序占用比进程内应用程序更多的内存资源

实现:通过MTS(跨进程处理)和(Web Application Manager,WAM)实现
inteinfo.exe外的新城已WAN_计算机名帐号执行

——-IIS5
提供了三个不同级别的应用程序保护
>低(IIS进程)与IIS的版本1~3最初的单一结构一样,作为WEB服务器进程(inetinfor.exe)的一部分在进程内运行
>中(共用的)作为一个单独的缓冲池进程在inetinfo.exe进程外运行,也就是说,它作为名为dllhost.exe的新
COM+宿主进程内部运行的几个应用程序之一
>高(独立的)在自己的隔离dllhost.exe进程中运行

——-IIS6
IIS 6与IIS 5之间的区别
1. HTTP请求由内核驱动程序HTTP.SYS处理,而不再是inetinfo.exe.
2. 支持两种新的应用程序隔离模型:
>工作进程隔离模型:全新的模型,它将用户开发的所有应用
程序代码与核心IIS服务完全隔离
>IIS 5隔离模型:为IIS 5设计的早期应用程序向后兼容
3.多个应用程序池的支持,可以单独配置每一个池
4.重新改造了WWW服务(W3SVC),包括了一个新的配置和进程管理部分,名为Web管理服务(WAS)
5.其他增强的特性:处理器相似性,运行状况监视,Web园,请求式启动,空闲超时,快速故障保护,工作进程回收,XML配置数据库等

——-IIS6观察:
在ComputerManagement的Services中查看
IIS Admin Service,对应程序为C:\WINDOWS\System32\inetsrv\inetinfo.exe

Web管理服务(W3SVC):World Wide Web Publishing Service,
对应程序为C:\WINDOWS\System32\svchost.exe -k iissvcs

HKLM\System\CurrentControlSet\Services\W3SVC
下的Parameters,有一个名为ServiceDll的value,其值为%systemroot%\System32\inetsrv\iisw3adm.dll
svchost.exe会根据这个记录来加载iisw3adm.dll

使用
netstat -a -b -n 来查看每个端口的侦听程序.
对于80端口,IIS5和IIS6有所不同.
IIS5 为inetinfo.exe
IIS6 为svchost.exe






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham