<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_Alen家的程序园</title><subtitle type="text"/><id>http://feed.cnblogs.com/blog/u/7073/rss</id><updated>2011-08-11T05:17:55Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><generator>CNBlogs BlogServer</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/7073/rss"/><entry><id>http://www.cnblogs.com/jacksonyin/archive/2011/08/11/2134839.html</id><title type="text">免费用电信的wifi</title><summary type="text">1、但凡你的手机能搜到中国电信的chinanet的热点覆盖，全国公免账号：07953591377，密码：3591377；2、全国通用麦当劳无线上网账号：McDonald-OC 密码：Ac28Idfjla92ifjsl3jsHdowIo M记WIFI账号密码，隐藏WIFI，要自己手动添加，理论全国通用。 账号密码需要区分大小写</summary><published>2011-08-11T05:18:00Z</published><updated>2011-08-11T05:18:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2011/08/11/2134839.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2011/08/11/2134839.html"/><content type="html">&lt;p&gt;1、但凡你的手机能搜到中国电信的chinanet的热点覆盖，全国公免账号：07953591377，密码：3591377；&lt;/p&gt;&lt;p&gt;2、全国通用麦当劳无线上&lt;br /&gt;网账号：McDonald-OC 密码：Ac28Idfjla92ifjsl3jsHdowIo &lt;br /&gt;M记WIFI账号密码，隐藏WIFI，要自己手动添加，理论全国通用。 账号密码需要区分大小写&lt;/p&gt;&lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/2134839.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2011/08/11/2134839.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2011/04/14/2016075.html</id><title type="text">简单反编译 chm 文件</title><summary type="text">这两天想反编译一个 chm 文件，上网爬了一堆工具，结果效果都不理想，最后找到这样一个简单的方法：使用微软 Windows 自带的 “Windows Html help Workshop”，运行后选择 DeCompile，一切轻松搞定。附：我用的 Win7 32bit，该工具所在的目录为：“C:\Program Files\HTML Help Workshop\hhw.exe”</summary><published>2011-04-14T07:21:00Z</published><updated>2011-04-14T07:21:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2011/04/14/2016075.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2011/04/14/2016075.html"/><content type="html">&lt;p&gt;这两天想反编译一个 chm 文件，上网爬了一堆工具，结果效果都不理想，最后找到这样一个简单的方法：&lt;/p&gt;&lt;p&gt;使用微软 Windows 自带的 &amp;#8220;&lt;strong style="color: rgb(255, 0, 0);"&gt;Windows Html help Workshop&lt;/strong&gt;&amp;#8221;，运行后选择 &lt;span style="color: rgb(255, 0, 0);"&gt;DeCompile&lt;/span&gt;，一切轻松搞定。&lt;/p&gt;&lt;p&gt;附：&lt;br /&gt;我用的 Win7 32bit，该工具所在的目录为：&lt;br /&gt;&amp;#8220;C:\Program Files\HTML Help Workshop\hhw.exe&amp;#8221;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/2016075.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2011/04/14/2016075.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2011/03/25/1995416.html</id><title type="text">如何减少silverlight XAP包的尺寸</title><summary type="text">这次得到了一个做Silverlight应用开发的机会，在发布时遇到 xap 包太大的问题，上网看了半天，最后把微软的这个文档 “如何使用应用程序库缓存” 翻来覆去看了半天，终于搞明白了它说的内容，晕啊，真应了 “会者不难” 这句老话。最后决定把这个其实很简单的东西总结一下，避免别的新学者浪费时间。 开发场景： Silverlight Application: 与Web交互, 程序集名：SilverlightApplication10.dll Silverlight Class Library: 被SilverlightApplication10引用，程序集名：SilverlightClassL</summary><published>2011-03-25T06:41:00Z</published><updated>2011-03-25T06:41:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2011/03/25/1995416.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2011/03/25/1995416.html"/><content type="html">&#xD;
&lt;p&gt;这次得到了一个做Silverlight应用开发的机会，在发布时遇到 xap 包太大的问题，上网看了半天，最后把微软的这个文档 &amp;#8220;&lt;a href="http://msdn.microsoft.com/zh-cn/library/dd833069%28v=vs.95%29.aspx"&gt;如何使用应用程序库缓存&lt;/a&gt;&amp;#8221; 翻来覆去看了半天，终于搞明白了它说的内容，晕啊，真应了 &amp;#8220;会者不难&amp;#8221; 这句老话。&lt;/p&gt;&lt;p&gt;最后决定把这个其实很简单的东西总结一下，避免别的新学者浪费时间。&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;开发场景：&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img border="0" alt="" src="http://images.cnblogs.com/cnblogs_com/jacksonyin/290444/o_001.png" /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;Silverlight Application: 与Web交互, 程序集名：SilverlightApplication10.dll    &lt;br /&gt;Silverlight Class Library: 被SilverlightApplication10引用，程序集名：SilverlightClassLibrary1.dll    &lt;br /&gt;目标：    &lt;br /&gt;编译后的ClientBin中，SilverlightApplication10.xap包中不包含SilverlightClassLibrary1.dll, SilverlightClassLibrary1.dll 以SilverlightClassLibrary1.zip新式单独存在。    &lt;br /&gt;OK, 现在说说这核心三部曲：    &lt;br /&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SilverlighApplication10工程属性里&amp;#8221;Silverlight&amp;#8221;标签下勾上 &amp;#8220;Reduce XAP size by using application library caching&amp;#8221;&lt;img border="0" alt="" src="http://images.cnblogs.com/cnblogs_com/jacksonyin/290444/o_002.png" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 在保存SilverlightClassLibrary1.dll的地方增加一个extmap文件&amp;#8221; SilverlightClassLibrary1.extmap.xml&amp;#8221;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;img border="0" alt="" src="http://images.cnblogs.com/cnblogs_com/jacksonyin/290444/o_003.png" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;SilverlightClassLibrary1.extmap.xml 的内容说明 &lt;/p&gt;  &lt;ol&gt;&lt;li&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;lt;manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:xsd="http://www.w3.org/2001/XMLSchema"&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp; &amp;lt;assembly&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;name&amp;gt;SilverlightClassLibrary1&amp;lt;/name&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;version&amp;gt;1.0.0.0&amp;lt;/version&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;publickeytoken&amp;gt;ee6c3f173c1a51b5&amp;lt;/publickeytoken&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;relpath&amp;gt;SilverlightClassLibrary1.dll&amp;lt;/relpath&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;extension downloadUri="SilverlightClassLibrary1.zip" /&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp; &amp;lt;/assembly&amp;gt;&lt;/li&gt;&lt;li&gt;&amp;lt;/manifest&amp;gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;name: SilverlightClassLibrary1 的程序集名字   &lt;br /&gt;version: assembly version.    &lt;br /&gt;publickeytoken: 打上签名后的public key    &lt;br /&gt;没什么太多解释的，微软的文档&amp;#8220;&lt;a href="http://msdn.microsoft.com/zh-cn/library/dd833069%28v=vs.95%29.aspx"&gt;如何使用应用程序库缓存&lt;/a&gt;&amp;#8221; 里说的很清楚了。对于version和publikeytoken如果你拿不准的话，可以用reflector看，简单直接:&lt;/p&gt;&lt;p&gt;&lt;img border="0" alt="" src="http://images.cnblogs.com/cnblogs_com/jacksonyin/290444/o_004.png" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;另外，extension downloadUri的内容注意别写错了，是 .zip结尾！我有个配置给copy成.dll了，老不成功，以为还需要设置别的配置，在快把我搞死的时候，才发现这儿写错了，唉......    &lt;br /&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SilverlightApplication10 不要引用SilverlightClassLibrary1的工程，要直接引用编译好的SilverlightClassLibrary1.dll    &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;img border="0" alt="" src="http://images.cnblogs.com/cnblogs_com/jacksonyin/290444/o_005.png" /&gt; &lt;br /&gt;OK，最后结果如图：    &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;img border="0" alt="" src="http://images.cnblogs.com/cnblogs_com/jacksonyin/290444/o_006.png" /&gt; &lt;br /&gt;清爽的xap包！把它改名成SilverlightApplication10.zip，打开看看：    &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;img border="0" alt="" src="http://images.cnblogs.com/cnblogs_com/jacksonyin/290444/o_007.png" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;最后，附上我的测试程序供大家参考：&lt;/p&gt;   &#xD;
&lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/1995416.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2011/03/25/1995416.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2011/03/25/1995401.html</id><title type="text">读书笔记 - .net2.0 异步编程模型： 使用 IAsyncResult 调用异步方法</title><summary type="text">微软早在.net2.0, 也就是VS2005的时候，就提供了一整套的异步编程设计模式，有3中常用的方式： 1. 使用 IAsyncResult 调用异步方法 2. 使用委托进行异步编程 3. 使用事件进行异步多线程编程 注： IAsyncResult 方式通常是用委托来实现的。所以可以认为前面2种方式就是一种。 http://msdn.microsoft.com/zh-cn/library/2e08f6yc.aspx 使用 IAsyncResult 调用异步方法 1. 有两个配对的方法，BeginXXX() 和 EndXXX()。它们是XXX()方法的异步执行。 BegingXXX()的参数是</summary><published>2011-03-25T06:33:00Z</published><updated>2011-03-25T06:33:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2011/03/25/1995401.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2011/03/25/1995401.html"/><content type="html">&lt;p&gt;微软早在.net2.0, 也就是VS2005的时候，就提供了一整套的异步编程设计模式，有3中常用的方式：&lt;/p&gt;  &lt;p&gt;1. 使用 &lt;strong&gt;IAsyncResult &lt;/strong&gt;调用异步方法&lt;/p&gt;  &lt;p&gt;2. 使用&lt;strong&gt;委托&lt;/strong&gt;进行异步编程&lt;/p&gt;  &lt;p&gt;3. 使用&lt;strong&gt;事件&lt;/strong&gt;进行异步多线程编程&lt;/p&gt;  &lt;p&gt;注： IAsyncResult 方式通常是用委托来实现的。所以可以认为前面2种方式就是一种。&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/zh-cn/library/2e08f6yc.aspx"&gt;http://msdn.microsoft.com/zh-cn/library/2e08f6yc.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;使用&lt;/strong&gt;&lt;strong&gt; IAsyncResult &lt;/strong&gt;&lt;strong&gt;调用异步方法&lt;/strong&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;1. 有两个配对的方法，BeginXXX() 和 EndXXX()。它们是XXX()方法的异步执行。&lt;/p&gt;  &lt;p&gt;BegingXXX()的参数是在XXX()的参数基础上增加 AsyncCallback 和 AsyncState。&lt;/p&gt;  &lt;p&gt;EndXXX()的返回值和XXX()的返回值是一样的。&lt;/p&gt;  &lt;p&gt;例如   &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&lt;div&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;delegate&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncMethodCaller((&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;param1,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;param2);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncDemo&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncMethodCaller&amp;nbsp;_asyncDelegate&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncMethodCaller(Run);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;IAsyncResult&amp;nbsp;BeginRun(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;param1,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;param2,&amp;nbsp;AsyncCallback&amp;nbsp;asyncCallBack,&amp;nbsp;Object&amp;nbsp;asyncState)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;11&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;13&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;asyncDelegate.BeginInvoke(param1,&amp;nbsp;param2,&amp;nbsp;callBack,&amp;nbsp;stateObject);&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;14&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;15&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;EndRun(IAsyncResult&amp;nbsp;asyncResult)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;17&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;19&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;20&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;m_asyncDelegate.EndInvoke(asyncResult);&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;21&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;22&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;23&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;Public&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;Run(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;param1,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;param2);&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;24&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;2. IAsyncResult 对象中存储有关异步操作的信息。&lt;/p&gt;  &lt;p&gt;3. 阻止应用程序执行的几种方法&lt;/p&gt;  &lt;p&gt;a. 通过结束异步操作来阻止应用程序执行&lt;/p&gt;  &lt;p&gt;就是EndXXX() 调用时，如果 IAsyncResult 对象表示异步操作未完成，则调用线程会被阻止，就是说它之后的逻辑的会被阻止。&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&lt;div&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;IAsyncResult&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncDemo.BeginRun(param1,&amp;nbsp;param2,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;AsyncDemo.EndRun(result);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&amp;nbsp;when&amp;nbsp;Run()&amp;nbsp;method&amp;nbsp;is&amp;nbsp;completed.&amp;nbsp;Continue&amp;nbsp;to&amp;nbsp;go.&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;6&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;7&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;ContinueToGo();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;b. 使用 AsyncWaitHandle 阻止应用程序的执行。&lt;/p&gt;  &lt;p&gt;在BeingXXX()之后调用 IAsyncResult.AsyncWAitHandle 中的相应方法也可以阻止调用线程。例如   &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&lt;div&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;IAsyncResult&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncDemo.BeginRun(param1,&amp;nbsp;param2,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;3&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&amp;nbsp;Wait&amp;nbsp;until&amp;nbsp;the&amp;nbsp;operation&amp;nbsp;completes.&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;4&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;5&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;result.AsyncWaitHandle.WaitOne();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;c. 轮询异步操作的状态。&lt;/p&gt;  &lt;p&gt;在BeingXXX()之后调轮询IAsyncResult.IsCompleted属性来确定此操作是否已完成   &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&lt;div&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;IAsyncResult&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncDemo.BeginRun(param1,&amp;nbsp;param2,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;While(result.IsCompleted&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;!=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&amp;nbsp;Waiting&amp;nbsp;until&amp;nbsp;IsCompleted&amp;nbsp;is&amp;nbsp;true.&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;//&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&amp;nbsp;when&amp;nbsp;Run()&amp;nbsp;method&amp;nbsp;is&amp;nbsp;completed.&amp;nbsp;Continue&amp;nbsp;to&amp;nbsp;go.&lt;/span&gt;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;11&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 128, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;ContinueToGo();&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&amp;nbsp; &lt;p&gt;d. 使用 AsyncCallback 委托结束异步操作。&lt;/p&gt;  &lt;p&gt;就是在代理里面根据具体情况调用Endxxx()方法来让调用线程继续运行。   &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="background-color: #F5F5F5;border: 1px solid #CCCCCC;padding-left:5px;padding-right:5px;"&gt;&lt;div&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;Public&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;MainFunc()&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;AsyncCallback&amp;nbsp;callBack&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncCallback(ProcessRun);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;IAsyncResult&amp;nbsp;result&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;=&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;AsyncDemo.BeginRun(param1,&amp;nbsp;param2,&amp;nbsp;callBack,&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;ContinueToGo()；&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;10&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;11&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;12&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;13&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;Public&amp;nbsp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&amp;nbsp;ProcessRun(IAsyncResult&amp;nbsp;result)&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;14&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;15&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;16&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;AsyncDemo.EndRun(result);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;17&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 128, 128);"&gt;18&lt;/span&gt;&amp;nbsp;&lt;span style="color: rgb(0, 0, 0);"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&amp;nbsp;&#xD;
 &lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/1995401.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2011/03/25/1995401.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2011/01/21/1941068.html</id><title type="text">测试绑定新浪微博</title><summary type="text">测试绑定新浪微博</summary><published>2011-01-21T05:34:00Z</published><updated>2011-01-21T05:34:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2011/01/21/1941068.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2011/01/21/1941068.html"/><content type="html">测试绑定新浪微博&lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/1941068.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2011/01/21/1941068.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2010/12/09/1900997.html</id><title type="text">(转)Debug Silverlight in FireFox</title><summary type="text">   If you set Firefox as your default browser. You cannot debug a Silverlight application easily. There is a workaround for this problem. Type "about:config" into FireFox's address bar Accept the warning (if applicable) Search for the entry "dom.ipc.plugins.enabled.npctrl.dll" Change its value from </summary><published>2010-12-09T03:12:00Z</published><updated>2010-12-09T03:12:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2010/12/09/1900997.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2010/12/09/1900997.html"/><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;If you set Firefox as your default browser. You cannot debug a Silverlight application easily. There is a workaround for this problem.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Type &amp;quot;about:config&amp;quot; into FireFox's address bar&lt;/li&gt;    &lt;li&gt;Accept the warning (if applicable)&lt;/li&gt;    &lt;li&gt;Search for the entry &amp;quot;dom.ipc.plugins.enabled.npctrl.dll&amp;quot;&lt;/li&gt;    &lt;li&gt;Change its value from &amp;quot;true&amp;quot; to &amp;quot;false&amp;quot; (double-click)&lt;/li&gt; &lt;/ol&gt; Restart the browser &lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/1900997.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2010/12/09/1900997.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2010/11/26/1888998.html</id><title type="text">[转]CLR 全面透彻解析 - 将 APTCA 程序集迁移到 .NET Framework 4</title><summary type="text">在 Microsoft .NET Framework 4 中，公共语言运行时 (CLR) 安全模型发生了不少变化。其中一项变化，即采用 Level2 透明性（与 Silverlight 的安全模型非常相似）很可能影响 AllowPartiallyTrustedCallers (APTCA) 库的作者。该影响源于 APTCA 的基础工作在 CLR v4 中发生了变化。APTCA 属性保持了向部分受信任调用方提供完全可信任库的功能，但具体的提供方式发生了变化，因此，有可能需要对 APTCA 库代码进行一些修改。注意：本篇文章中的 v2 是指 CLR v2，它包括从 .NET Framework versions 2.0 到 3.5 SP1 的所有版本。</summary><published>2010-11-26T09:16:00Z</published><updated>2010-11-26T09:16:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2010/11/26/1888998.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2010/11/26/1888998.html"/><content type="html">&lt;p&gt;原文链接：&lt;a href="http://msdn.microsoft.com/zh-cn/magazine/ee336023.aspx"&gt;http://msdn.microsoft.com/zh-cn/magazine/ee336023.aspx&lt;/a&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;将 APTCA 程序集迁移到 .NET Framework 4&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;a id="ctl00_MTContentSelector1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl01',this);" href="http://www.cnblogs.com/jacksonyin/admin/ee532098.aspx?sdmr=MikeRousos&amp;amp;sdmi=authors"&gt;&lt;font color="#0066dd"&gt;&lt;strong&gt;Mike Rousos&lt;/strong&gt; &lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&#xD;
&lt;p&gt;在 Microsoft .NET Framework 4 中，公共语言运行时 (CLR) 安全模型发生了不少变化。其中一项变化，即采用 Level2 透明性（与 Silverlight 的安全模型非常相似）很可能影响 AllowPartiallyTrustedCallers (APTCA) 库的作者。&lt;/p&gt;&#xD;
&lt;p&gt;该影响源于 APTCA 的基础工作在 CLR v4 中发生了变化。APTCA 属性保持了向部分受信任调用方提供完全可信任库的功能，但具体的提供方式发生了变化，因此，有可能需要对 APTCA 库代码进行一些修改。&lt;/p&gt;&#xD;
&lt;p&gt;注意：本篇文章中的 v2 是指 CLR v2，它包括从 .NET Framework versions 2.0 到 3.5 SP1 的所有版本。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;V4 之前的 APTCA&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;在 v4 之前，通过对所有入口点的完全信任隐式链接要求，所有签名程序集都受到保护，不提供给部分受信任调用方。这意味着，任何部分受信任代码在尝试访问强名称的程序集时都因为安全性异常而失败。这会阻止部分受信任调用方恶意调用（存在潜在风险的）完全受信任代码。&lt;/p&gt;&#xD;
&lt;p&gt;将 AllowPartiallyTrustedCallers 属性添加到签名的完全受信任库后，可对这些库移除这些隐式链接要求，从而可供部分受信任方使用。因此，APTCA 库通过 APTCA 公开的方法允许部分受信任代码以受控的方式访问特权操作。APTCA 作者有责任确保通过这种方式只向部分受信任方公开安全操作，任何存在潜在风险的操作都应通过隐式链接要求或完整要求加以保护。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;V4 中的 APTCA&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;AllowPartiallyTrustedCallers 属性已发生变化。v4 再不用考虑链接要求。事实上，曾在 v2 中存在的对签名库的隐式链接要求已不复存在。而 v4 中所有完全受信任程序集在默认情况下都属于 SecurityCritical。另一方面，v4 中所有部分受信任程序集在默认情况下均属于 SecurityTransparent。正如下一部分的透明性概述中所言，SecurityTransparent 代码将无法调用 SecurityCritical 代码。&lt;/p&gt;&#xD;
&lt;p&gt;因此，新 v4 透明性系统对完全受信任代码提供与旧的链接要求相同的保护；由于 SecurityCritical 和 SecurityTransparent 是自动应用的透明性级别，部分受信任代码默认情况下无法调用完全受信任的库。&lt;/p&gt;&#xD;
&lt;p&gt;您可能猜到，v4 中对 AllowPartiallyTrustedCallers 的更改与此有关。在 v4 中，APTCA 的变化是从应用 SecurityCritical 的程序集取消了自动 SecurityCritical 行为。因此程序集默认为 SecurityTransparent，但允许 APTCA 程序集作者在必要时对特定类型和方法应用更加具体的 SecurityCritical 和 SecuritySafeCritical 属性。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;透明性速成教程&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;熟悉 Silverlight 安全模型的读者对于 SecurityTransparent 和 SecurityCritical 等透明性属性的作用并不会感到陌生，因为新 v4 透明性模型与 Silverlight 安全模型非常相似。&lt;/p&gt;&#xD;
&lt;p&gt;让我们先来了解一下三个主要的透明性属性：SecurityTransparent、SecuritySafeCritical 和 SecurityCritical。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;SecurityTransparent&lt;/strong&gt;：标记为 SecurityTransparent 的代码从安全性角度而言是可靠的。它不能完成任何危险操作，例如声明权限、执行无法验证的代码或调用本机代码。它也不能直接调用 SecurityCritical 代码。&lt;/p&gt;&#xD;
&lt;ul&gt;&lt;li&gt;如上文所述，出于安全的考虑，所有部分受信任代码都强制为 SecurityTransparent。这也是 APTCA 库的默认透明性。&lt;/li&gt;&lt;/ul&gt;&#xD;
&lt;p&gt;&lt;strong&gt;SecurityCritical&lt;/strong&gt;：与 SecurityTransparent 不同，SecurityCritical 代码能够执行任何所需操作。它能够执行声明、调用本机代码和其他操作。它能够调用其他方法，且不受透明性标记的限制。&lt;/p&gt;&#xD;
&lt;ul&gt;&lt;li&gt;只有完全受信任代码才能为 SecurityCritical。事实上，（非 APTCA）完全受信任代码默认情况下属于 SecurityCritical，从而保护其免受透明的部分受信任调用方的调用。&lt;/li&gt;&lt;/ul&gt;&#xD;
&lt;p&gt;&lt;strong&gt;SecuritySafeCritical&lt;/strong&gt;：SecuritySafeCritical 代码起着桥梁的作用，它允许透明代码调用关键方法。SecuritySafeCritical 代码与 SecurityCritical 代码的权限相同，但它可由 SecurityTransparent 代码调用。因此，SecuritySafeCritical 代码必须以安全方式公开基础 SecurityCritical 方法（以避免一些部分受信任的恶意代码尝试通过 SecuritySafeCritical 层攻击这些方法），这一点极为重要。&lt;/p&gt;&#xD;
&lt;ul&gt;&lt;li&gt;与 SecurityCritical 代码一样，SecuritySafeCritical 代码必须完全受信任。&lt;/li&gt;&lt;/ul&gt;&#xD;
&lt;p&gt;&lt;strong&gt;图 1&lt;/strong&gt; 描述了 SecurityTransparent、SecuritySafeCritical 和 SecurityCritical 代码之间的内在关系。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;img alt="" src="http://i.msdn.microsoft.com/ee336023.Rousos_Figure1(en-us,MSDN.10).png" /&gt; &lt;br /&gt;图 1 &lt;strong&gt;SecurityTransparent、SecuritySafeCritical 和 SecurityCritical 代码之间的内在关系&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;注意：除了图中所示的转换关系外，所有透明性级别都可以访问自身以及任何重要性级别较低的代码（例如，SecuritySafeCritical 代码可以访问 SecurityTransparent 代码）。AllowPartiallyTrustedCallers 属性使整个程序集默认情况下是 SecurityTransparent，因此，程序集作者必须将需要执行特权操作的方法专门标记为 SecurityCritical 或 SecuritySafeCritical。如果不进行这样的标记，APTCA 作者将会发现其代码因 MethodAccessExceptions、TypeAccessExceptions 和其他错误导致执行失败，这些错误指示 APTCA 库正在尝试从 SecurityTransparent 代码调用危险 API。&lt;/p&gt;&#xD;
&lt;p&gt;此处仅对该模型进行了简介，如需了解详细信息，请访问 MSDN 文档和 Andrew Dai 之前的文章&amp;#8220;CLR 全面透彻解析&amp;#8221;（文章地址：&lt;a id="ctl00_MTContentSelector1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl03',this);" href="http://www.cnblogs.com/jacksonyin/admin/ee677170.aspx"&gt;&lt;font color="#0066dd"&gt;msdn.microsoft.com/magazine/ee677170.aspx&lt;/font&gt;&lt;/a&gt;）。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;从 V2 迁移到 V4：要应用的属性&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;从 v2 APTCA 程序集迁移到 v4 的大部分工作涉及标识正确的透明属性并将其应用到需要它们的方法。下列指导原则对属性的选择进行了说明。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;SecurityTransparent&lt;/strong&gt;：不能执行任何安全敏感操作的代码应属于 SecurityTransparent。&lt;/p&gt;&#xD;
&lt;p&gt;与其他透明性设置不同，SecurityTransparent 行为在 APTCA 程序集中是默认行为属性，因此无需对其进行显式标记。如果无其他属性，代码将默认为透明。&lt;/p&gt;&#xD;
&lt;p&gt;透明代码的一个优势在于其安全性（因为不允许执行危险操作），因此对它的安全性审查没有 SecurityCritical 尤其是 SecuritySafeCritical 代码那么严格。建议您尽量对代码使用 SecurityTransparent。&lt;/p&gt;&#xD;
&lt;p&gt;在 SecurityTransparent 代码中禁止执行下列操作：&lt;/p&gt;&#xD;
&lt;ul&gt;&lt;li&gt;调用 SecurityCritical 方法&lt;/li&gt;&lt;li&gt;声明权限或权限集&lt;/li&gt;&lt;li&gt;使用无法验证的代码&lt;/li&gt;&lt;li&gt;调用非托管代码&lt;/li&gt;&lt;li&gt;重写 SecurityCritical 的虚拟方法&lt;/li&gt;&lt;li&gt;实现 SecurityCritical 接口&lt;/li&gt;&lt;li&gt;从任何非 SecurityTransparent 类型派生&lt;/li&gt;&lt;/ul&gt;&#xD;
&lt;p&gt;&lt;strong&gt;SecuritySafeCritical&lt;/strong&gt;：如果代码可以由部分受信任调用方调用，但又需要能够调用潜在危险的 API，则此代码应标记为 SecuritySafeCritical。通常，要求权限的方法属于此类，因为它们代表介于部分受信任代码和特权操作之间的受保护边界。&lt;/p&gt;&#xD;
&lt;p&gt;由于 SecuritySafeCritical 代码允许部分受信任调用方间接访问危险 API，这是一个非常强大的属性，应对其应用持谨慎和保守的态度。SecuritySafeCritical 代码必须以特定、安全的方式对其调用方公开 SecurityCritical 功能。通常，一个较好的做法是让 SecuritySafeCritical 代码包含要求，以确保调用方能够访问 SecuritySafeCritical 代码将使用的特定资源。对 SecuritySafeCritical 代码而言，验证输入和输出也非常重要，从而确保不传递无效的值，以及任何返回的信息能够安全地交给部分受信任调用方。&lt;/p&gt;&#xD;
&lt;p&gt;由于可能存在安全风险，建议尽量少用 SecuritySafeCritical 代码。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;SecurityCritical&lt;/strong&gt;：如果向部分受信任调用方公开代码存在风险，则此代码应标记为 SecurityCritical。之前受链接要求保护的方法可能需要此属性。&lt;/p&gt;&#xD;
&lt;p&gt;SecurityCritical 代码的危险性低于 SecuritySafeCritical，因为透明调用方（部分受信任方）不能直接对其进行调用。然而，此代码能够执行很多高安全性操作。因此，为了将对安全审查的需求降至最低，最好也尽量少用 SecurityCritical 代码。&lt;/p&gt;&#xD;
&lt;p&gt;一般原则是尽可能将代码标记为 SecurityTransparent。其他代码则应标记为 SecurityCritical，除非明确期望透明代码将通过其访问 SecurityCritical 代码，则将该代码标记为 SecuritySafeCritical。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;使用 SecAnnotate.exe&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;为了帮助正确应用透明性属性，可以使用新的 .NET Framework SDK 工具 Security Annotator (SecAnnotate.exe)。此工具使用用户的二进制数据（或二进制集合），并提供有关在何处应用透明性属性的指导。该工具在将 APTCA 库迁移到 v4 时非常有帮助。&lt;/p&gt;&#xD;
&lt;p&gt;SecAnnotate 的工作原理是数次遍历目标二进制数据，查找根据 CLR 规则需要标上透明性属性的方法。在随后的遍历中，该工具会根据之前遍历中建议的修改而查找必要的属性。例如，考虑下面一小段代码（假定其来自 APTCA 程序集）：&lt;/p&gt;&lt;span id="ctl00_MTContentSelector1_mainContentContainer_ctl04"&gt;&#xD;
&lt;div id="ctl00_MTContentSelector1_mainContentContainer_ctl04_" &gt;&#xD;
&lt;div &gt;&#xD;
&lt;div &gt;&lt;/div&gt;&#xD;
&lt;div &gt;&lt;a  title="复制代码" href="http://www.cnblogs.com/jacksonyin/admin/javascript:CopyCode('ctl00_MTContentSelector1_mainContentContainer_ctl04_code');"&gt;&#xD;
&lt;div style="border-bottom: 0px; border-left: 0px; width: auto; height: 9px; border-top: 0px; border-right: 0px"  align="center"&gt;&lt;/div&gt;复制代码 &lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;div style="background-color: #ddd" dir="ltr"&gt;&lt;pre id="ctl00_MTContentSelector1_mainContentContainer_ctl04_code"  space="preserve"&gt;static void Method1()&#xD;
{&#xD;
      Console.WriteLine("In method 1!");&#xD;
      Method2();&#xD;
}&#xD;
&#xD;
static void Method2()&#xD;
{&#xD;
      PermissionSet ft = new PermissionSet(PermissionState.Unrestricted);&#xD;
      ft.Assert();&#xD;
      DangerousAPI();&#xD;
      PermissionSet.RevertAssert();&#xD;
}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p&gt;SecAnnotate.exe 将立即注意到 Method2 不能为透明，因为它声明了一些权限。第一次遍历后，工具将确定 Method2 不是 SecurityCritical 就是 SecuritySafeCritical（除非透明代码需要专门访问此方法，否则它很有可能属于 SecurityCritical）。&lt;/p&gt;&#xD;
&lt;p&gt;第一次遍历二进制数据时，Method1 似乎并未引起工具的注意。但在第二次遍历时，工具将注意到 Method1 正在调用 Method2，正如 SecAnnotate 在第一次遍历时所建议的，Method2 成为 SecurityCritical。鉴于此，Method1 同样应该属于 SecurityCritical（作者也可根据自己的判断将其归于 SecuritySafeCritical）。经过两次遍历后，SecAnnotate 建议将这两种方法都标记为 SecurityCritical。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;理解 SecAnnotate.exe 输出&lt;/strong&gt; &lt;/p&gt;&#xD;
&lt;p&gt;Security Annotator 的输出是 XML 文件，其中包含发现的问题以及建议的解决方法。有时，Security Annotator 可能在后续的遍历中推翻之前的建议。如果出现这种情况，XML 文件将显示两次的建议。此时，您需要查看遍历编号，以清楚哪一项是最新建议，即正确的建议。&lt;/p&gt;&#xD;
&lt;p&gt;例如，让我们来考虑一下&lt;strong&gt;图 2&lt;/strong&gt; 中的 Security Annotator 输出。注意：在方法 Logging.MethodA 的批注标记下有两个元素：一个 SecuritySafeCritical 标记和一个 SecurityCritical 标记。这表示 SecAnnotate 在分析过程中建议此方法使用 SecurityCritical 和 SecuritySafeCritical 属性。&lt;/p&gt;&#xD;
&lt;p&gt;图 2 &lt;strong&gt;Security Annotator 输出&lt;/strong&gt;&lt;/p&gt;&lt;span id="ctl00_MTContentSelector1_mainContentContainer_ctl05"&gt;&#xD;
&lt;div id="ctl00_MTContentSelector1_mainContentContainer_ctl05_" &gt;&#xD;
&lt;div &gt;&#xD;
&lt;div &gt;&lt;/div&gt;&#xD;
&lt;div &gt;&lt;a  title="复制代码" href="http://www.cnblogs.com/jacksonyin/admin/javascript:CopyCode('ctl00_MTContentSelector1_mainContentContainer_ctl05_code');"&gt;&#xD;
&lt;div style="border-bottom: 0px; border-left: 0px; width: auto; height: 9px; border-top: 0px; border-right: 0px"  align="center"&gt;&lt;/div&gt;复制代码 &lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;div style="background-color: #ddd" dir="ltr"&gt;&lt;pre id="ctl00_MTContentSelector1_mainContentContainer_ctl05_code"  space="preserve"&gt;&amp;lt;requiredAnnotations&amp;gt;&#xD;
    &amp;lt;assembly name="Logging"&amp;gt;&#xD;
      &amp;lt;type name="Logging"&amp;gt;&#xD;
        &amp;lt;method name="MethodA()"&amp;gt;&#xD;
          &amp;lt;annotations&amp;gt;&#xD;
            &amp;lt;safeCritical&amp;gt;&#xD;
              &amp;lt;rule name="MethodsMustOverrideWithConsistentTransparency"&amp;gt;&#xD;
                &amp;lt;reason pass="2" sourceFile="d:\repro\aptca\logging.cs" sourceLine="67"&amp;gt;Critical method Logging.MethodA()&amp;#8217; is overriding transparent or safe critical method &amp;#8216;Logging.MethodA()&amp;#8217; in violation of method override rules.  Logging.MethodA()&amp;#8217; must become transparent or safe-critical in order to override a transparent or safe-critical virtual method or implement a transparent or safe-critical interface method.&amp;lt;/reason&amp;gt;&#xD;
              &amp;lt;/rule&amp;gt;&#xD;
            &amp;lt;/safeCritical&amp;gt;&#xD;
            &amp;lt;critical&amp;gt;&#xD;
              &amp;lt;rule name="TransparentMethodsMustNotSatisfyLinkDemands"&amp;gt;&#xD;
                &amp;lt;reason pass="1" sourceFile="d:\repro\aptca\logging.cs" sourceLine="68"&amp;gt;Security transparent method Logging.MethodA()&amp;#8217; satisfies a LinkDemand for &amp;#8216;FileIOPermissionAttribute&amp;#8217; on method &amp;#8216;Logging.set_LogLocation(System.String)&amp;#8217;.  Logging.MethodA()&amp;#8217; should become critical or safe-critical in order to call &amp;#8216;Logging.set_LogLocation(System.String)&amp;#8217;.&amp;lt;/reason&amp;gt;&#xD;
              &amp;lt;/rule&amp;gt;&#xD;
            &amp;lt;/critical&amp;gt;&#xD;
          &amp;lt;/annotations&amp;gt;&#xD;
        &amp;lt;/method&amp;gt;&#xD;
      &amp;lt;/type&amp;gt;&#xD;
    &amp;lt;/assembly&amp;gt;&#xD;
  &amp;lt;/requiredAnnotations&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p&gt;对 SecurityCritical 元素的解释表示由于此方法正在调用受链接要求保护的内容，因此它不是 SecurityCritical 就是 SecuritySafeCritical。SecAnnotate.exe 默认情况下建议选择 SecurityCritical，因为它更加安全。注意：此处的遍历属性值为 1，这表示此建议来自 SecAnnotate.exe 对代码的第一次遍历。&lt;/p&gt;&#xD;
&lt;p&gt;接着对 SecuritySafeCritical 的建议表示 MethodA 正在重写透明基方法，因此必须为 SecurityTransparent 或 SecuritySafeCritical（必须具有与基方法相同的可访问性）。综合考虑此信息和之前的建议，SecAnnotate.exe 建议 MethodA 采用 SecuritySafeCritical。&lt;/p&gt;&#xD;
&lt;p&gt;注意：pass="2" 表示此建议来自 SecAnnotate.exe 对代码的第二次遍历。这是因为在第一次遍历中，工具不知道 MethodA 不能为透明，因此没有意识到对 SecuritySafeCritical 的要求。&lt;/p&gt;&#xD;
&lt;p&gt;由于 SecuritySafeCritical 建议源于第二次（最新）遍历，因此在此例中它是正确的批注。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;SecAnnotate.exe 最佳实践&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;如果 SecurityCritical 和 SecuritySafeCritical 都是正确的标记，Security Annotator 优先选择代码已有的属性，其次选择 SecurityCritical，因为它的风险较小。不幸的是，这样做得到的代码虽然很安全，但在沙盒中却不可利用，因为将对部分受信任调用方堵塞所有入口点。&lt;/p&gt;&#xD;
&lt;p&gt;请牢记，如果 API 应由透明/部分受信任代码直接调用并且已考虑此点进行过安全审查，则这些 API 适用 SecuritySafeCritical。由于 Security Annotator 无法知道哪些 API 计划由部分受信任调用方调用，无法知道通过这种方式调用是否安全，因此它只会将很少的 API 标记为 SecuritySafeCritical。库作者必须手动将 SecuritySafeCritical 属性应用到某些方法，即便在使用 Security Annotator 时也如此。&lt;/p&gt;&#xD;
&lt;p&gt;由于在透明代码中发生一次受到禁止的操作，就有可能导致在 Security Annotator 的后续遍历中繁衍出许多 SecurityCritical 标记而不是导致策略性地放置 SecuritySafeCritical 标记，因此为 SecAnnotate.exe 使用 /p 命令行开关是不错的选择。开关 /p:x（x 表示数字）指示 Security Annotator 仅运行 x 次遍历，无需运行到完成所有必需的更改为止。下面是使用 Security Annotator 的一种好方法：&lt;/p&gt;&#xD;
&lt;ol&gt;&lt;li&gt;运行 SecAnnotate.exe /p:1 /d:&amp;lt;被引用程序集路径&amp;gt; &amp;lt;FileName.dll&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a. 这将在需要时添加透明性属性，但仅针对单次遍历。如果到此为止，作者可以手动检查属性。&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b. 默认情况下，SecAnnotate.exe 仅在 GAC 中寻找它所批注的程序集的依赖关系。其他程序集必须通过 /d 开关指定路径。&lt;/li&gt;&lt;li&gt;使用建议属性更新库的源文件。但也要考虑出现多个属性的情况，然后选择正确的属性。在某些情况下，尽管 SecAnnotate 偏好 SecurityCritical，但 SecuritySafeCritical 才是正确的属性。&lt;/li&gt;&lt;li&gt;重新生成程序集，并从步骤 1 重复（不带 /p:1）。可以反复使用 /p:1 重新运行程序，但您无需这样做，因为在第一次迭代步骤 2 之后便已得到所需 SecuritySafeCritical 属性。&lt;/li&gt;&lt;/ol&gt;&#xD;
&lt;p&gt;包含开发人员手动干预的迭代流程将产生批注正确的程序集，从而得到最多的透明代码。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;确定和检查 SecuritySafeCritical API&lt;/strong&gt; &lt;/p&gt;&#xD;
&lt;p&gt;如前文所述，SecAnnotate.exe 通常建议 API 不是 SecurityCritical 就是 SecuritySafeCritical。主要区别在于部分受信任调用方是否能够安全地调用 API。如果 API 经过所有验证可以确保基础关键或本机 API 能够被安全（例如通过要求或输入和输出验证）调用，则它可以标记为 SecuritySafeCritical，此属性有时更加理想，因此它允许 API 的调用方是透明的。另一方面，如果恶意代码有可能通过 API 访问受保护的资源，则该 API 必须保持为 SecurityCritical。&lt;/p&gt;&#xD;
&lt;p&gt;有必要仔细检查所有 SecuritySafeCritical 代码，以确定在其公开给部分受信任调用方后的安全影响。尽管 SecuritySafeCritical 和 SecurityCritical 代码都应尽量少用，但如果对于哪个属性合适心存疑虑，则 SecurityCritical 是较安全的选择。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;应用透明性属性&lt;/strong&gt; &lt;/p&gt;&#xD;
&lt;p&gt;应用透明性属性和在代码中应用任何其他 .NET 属性一样简单。MSDN 中提供了下列属性类型的使用文档：&lt;/p&gt;&#xD;
&lt;ul&gt;&lt;li&gt;SecurityTransparentAttribute&lt;br /&gt;注意：此属性只应用于程序集级别。在此情况下，它意味着程序集中的所有类型和方法都是透明的。在类型或方法级别没有必要使用此属性，因为它是 APTCA 程序集中的默认透明性设置。&lt;/li&gt;&lt;li&gt;SecuritySafeCriticalAttribute&lt;/li&gt;&lt;li&gt;SecurityCriticalAttribute&lt;/li&gt;&lt;/ul&gt;&#xD;
&lt;p&gt;在 C# 中，属性的应用与下列代码类似：&lt;/p&gt;&lt;span id="ctl00_MTContentSelector1_mainContentContainer_ctl06"&gt;&#xD;
&lt;div id="ctl00_MTContentSelector1_mainContentContainer_ctl06_" &gt;&#xD;
&lt;div &gt;&#xD;
&lt;div &gt;&lt;/div&gt;&#xD;
&lt;div &gt;&lt;a  title="复制代码" href="http://www.cnblogs.com/jacksonyin/admin/javascript:CopyCode('ctl00_MTContentSelector1_mainContentContainer_ctl06_code');"&gt;&#xD;
&lt;div style="border-bottom: 0px; border-left: 0px; width: auto; height: 9px; border-top: 0px; border-right: 0px"  align="center"&gt;&lt;/div&gt;复制代码 &lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;div style="background-color: #ddd" dir="ltr"&gt;&lt;pre id="ctl00_MTContentSelector1_mainContentContainer_ctl06_code"  space="preserve"&gt;[SecurityCritical]&#xD;
public static void Method1()&#xD;
{ /* Do something potentially dangerous*/ }&#xD;
&#xD;
[SecuritySafeCritical]&#xD;
public static void Method2()&#xD;
{ /* Do something potentially dangerous in a safe way that can be called from partial trust */ }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;Level1 和 Level2&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;关于透明性和 APTCA 的最后一点说明是：可以通过使用程序集级别的属性来使用较旧的 v2 APTCA 行为而非新 v4 行为。但不建议您这么做，这是因为新模型更安全，更易于审核，并且在 Silverlight 和桌面 CLR 之间通用。当然，在迁移之前，有时在短期内还是会存在兼容性问题。在这种情况下，您可以使用 SecurityRules 属性强制程序集使用较旧的 v2 规则。&lt;/p&gt;&#xD;
&lt;p&gt;SecurityRules 属性采用 SecurityRuleSet 枚举类型的参数。SecurityRuleSet.Level1 指定兼容性。SecurityRuleSet.Level2 指定新模型，但 Level2 属性并非必需，因为它是默认设置。但它能够用于显式指示使用中的透明性规则集，并防止将来对 .NET Framework 默认规则集的更改。&lt;/p&gt;&#xD;
&lt;p&gt;在 C# 中，此属性的应用如下所示：&lt;/p&gt;&lt;span id="ctl00_MTContentSelector1_mainContentContainer_ctl07"&gt;&#xD;
&lt;div id="ctl00_MTContentSelector1_mainContentContainer_ctl07_" &gt;&#xD;
&lt;div &gt;&#xD;
&lt;div &gt;&lt;/div&gt;&#xD;
&lt;div &gt;&lt;a  title="复制代码" href="http://www.cnblogs.com/jacksonyin/admin/javascript:CopyCode('ctl00_MTContentSelector1_mainContentContainer_ctl07_code');"&gt;&#xD;
&lt;div style="border-bottom: 0px; border-left: 0px; width: auto; height: 9px; border-top: 0px; border-right: 0px"  align="center"&gt;&lt;/div&gt;复制代码 &lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;div style="background-color: #ddd" dir="ltr"&gt;&lt;pre id="ctl00_MTContentSelector1_mainContentContainer_ctl07_code"  space="preserve"&gt;[assembly:SecurityRules(SecurityRuleSet.Level1)]&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;常见缺陷&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;APTCA 库作者在从 v2 迁移到 v4 时应注意下列常见问题：&lt;/p&gt;&#xD;
&lt;ul&gt;&lt;li&gt;SecAnnotate.exe 会建议将 LinkDemands 更改为 SecurityCritical 属性（这与对 FullTrust 的 LinkDemands 非常相似）。但如果类型（而非方法）原来由 LinkDemand 保护，这与在 v4 中向类型应用 SecurityCritical 不同。最好对类型的所有成员应用 SecurityCritical，因为这与 v2 类型级别的 LinkDemand 更为相似。&lt;/li&gt;&lt;li&gt;注意，有些部分受信任代码应该可以满足某些低权限 LinkDemand，将这些 LinkDemand 转换为 SecurityCritical 不一定是最好的选择。如果 LinkDemand 针对的是低权限（例如，对特定安全路径的读取权限），您最好移除 LinkDemand 并将其替换为针对相同权限的完整要求。这将使部分受信任代码能够继续调用 API（但该要求将确保仅具有足够权限的部分受信任代码才能进行调用）。&lt;/li&gt;&lt;li&gt;通常，类型级别的透明性属性也会应用到它们修改的类型的成员。最外层的属性将取代其他属性。因此，如果方法所在的类型应用了 [SecuritySafeCritical]，那么对该方法应用 [SecurityCritical] 将无效。通常，[SecuritySafeCritical] 在类型级别不是一个有用的属性。如果有人日后向类型添加新成员，但并未意识到它是 SecuritySafeCritical（源于类型级别属性），就可能导致安全漏洞，这种情况很可能发生。&lt;/li&gt;&lt;/ul&gt;&#xD;
&lt;p&gt;尽管类型级别的属性应用到他们修改的新类型的插槽成员，但不会应用到重写的成员。如果您使用类型级别的透明性属性，在需要时务必专门将属性添加到重写成员。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;迁移示例&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;图 3&lt;/strong&gt; 是一个在 v2 中编写的简单（但不完整）的日志库。&lt;/p&gt;&#xD;
&lt;p&gt;图 3 &lt;strong&gt;V2 APTCA 库&lt;/strong&gt;&lt;/p&gt;&lt;span id="ctl00_MTContentSelector1_mainContentContainer_ctl08"&gt;&#xD;
&lt;div id="ctl00_MTContentSelector1_mainContentContainer_ctl08_" &gt;&#xD;
&lt;div &gt;&#xD;
&lt;div &gt;&lt;/div&gt;&#xD;
&lt;div &gt;&lt;a  title="复制代码" href="http://www.cnblogs.com/jacksonyin/admin/javascript:CopyCode('ctl00_MTContentSelector1_mainContentContainer_ctl08_code');"&gt;&#xD;
&lt;div style="border-bottom: 0px; border-left: 0px; width: auto; height: 9px; border-top: 0px; border-right: 0px"  align="center"&gt;&lt;/div&gt;复制代码 &lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;div style="background-color: #ddd" dir="ltr"&gt;&lt;pre id="ctl00_MTContentSelector1_mainContentContainer_ctl08_code"  space="preserve"&gt;using System;&#xD;
using System.IO;&#xD;
using System.Security;&#xD;
using System.Security.Permissions;&#xD;
&#xD;
// This assembly is meant to be representative of a simple v2 APTCA assembly&#xD;
// It has some dangerous code protected with demands/link demands&#xD;
// It exposes some dangerous code in a controlled way with an assert&#xD;
&#xD;
[assembly: AllowPartiallyTrustedCallers]&#xD;
public class Logging&#xD;
{&#xD;
    private string logLocation = @"C:\temp\firstfoo.txt";&#xD;
&#xD;
    public virtual string Usage()&#xD;
    {&#xD;
        return "This is a helpful string";&#xD;
    }&#xD;
&#xD;
    public virtual string LogLocation&#xD;
    {&#xD;
        get&#xD;
        {&#xD;
            return logLocation;&#xD;
        }&#xD;
&#xD;
        [FileIOPermissionAttribute(SecurityAction.LinkDemand, Unrestricted=true)]&#xD;
        set&#xD;
        {&#xD;
            logLocation = value;&#xD;
        }&#xD;
    }&#xD;
&#xD;
    public virtual void SetLogLocation(int index)&#xD;
    {&#xD;
        switch (index)&#xD;
        {&#xD;
            case 1: &#xD;
                LogLocation = @"C:\temp\foo.txt";&#xD;
                break;&#xD;
            case 2:&#xD;
                LogLocation = @"D:\temp\foo.txt";&#xD;
                break;&#xD;
            case 3:&#xD;
                LogLocation = @"D:\repro\temp\foo.txt";&#xD;
                break;&#xD;
            default:&#xD;
                break;&#xD;
        }&#xD;
    }&#xD;
&#xD;
&#xD;
    public virtual void DeleteLog()&#xD;
    {&#xD;
        FileIOPermission fp = new FileIOPermission(FileIOPermissionAccess.AllAccess, LogLocation);&#xD;
        fp.Assert();&#xD;
        if (File.Exists(LogLocation)) { File.Delete(LogLocation); }&#xD;
        SecurityPermission.RevertAll();&#xD;
    }&#xD;
&#xD;
    // TODO : Put other APIs (creating log, writing to log, etc) here&#xD;
}&#xD;
&#xD;
public class OtherLogging : Logging&#xD;
{&#xD;
    public override string Usage()&#xD;
    {&#xD;
        LogLocation = null;&#xD;
        return "This is a different useful string";&#xD;
    }&#xD;
&#xD;
    // TODO : Put other APIs (creating log, writing to log, etc) here&#xD;
}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;图 4&lt;/strong&gt; 显示的是迁移到 v4 的同一个库，附带解释变化的注释文字（斜体）。&lt;/p&gt;&#xD;
&lt;p&gt;图 4 &lt;strong&gt;V4 APTCA 库&lt;/strong&gt;&lt;/p&gt;&lt;span id="ctl00_MTContentSelector1_mainContentContainer_ctl09"&gt;&#xD;
&lt;div id="ctl00_MTContentSelector1_mainContentContainer_ctl09_" &gt;&#xD;
&lt;div &gt;&#xD;
&lt;div &gt;&lt;/div&gt;&#xD;
&lt;div &gt;&lt;a  title="复制代码" href="http://www.cnblogs.com/jacksonyin/admin/javascript:CopyCode('ctl00_MTContentSelector1_mainContentContainer_ctl09_code');"&gt;&#xD;
&lt;div style="border-bottom: 0px; border-left: 0px; width: auto; height: 9px; border-top: 0px; border-right: 0px"  align="center"&gt;&lt;/div&gt;复制代码 &lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;div style="background-color: #ddd" dir="ltr"&gt;&lt;pre id="ctl00_MTContentSelector1_mainContentContainer_ctl09_code"  space="preserve"&gt;using System;&#xD;
using System.IO;&#xD;
using System.Security;&#xD;
using System.Security.Permissions;&#xD;
&#xD;
// This assembly is meant to be representative of a simple v2 APTCA assembly&#xD;
// It has some dangerous code protected with demands/link demands&#xD;
// It exposes some dangerous code in a controlled way with an assert&#xD;
&#xD;
[assembly: AllowPartiallyTrustedCallers]&#xD;
public class Logging&#xD;
{&#xD;
    private string logLocation = @"C:\temp\firstfoo.txt";&#xD;
	&#xD;
    // This API can be transparent because it does nothing dangerous.&#xD;
    // Transparent APIs need no attributes because it is the default behavior of a v4&#xD;
    // APTCA assembly&#xD;
    public virtual string Usage()&#xD;
    {&#xD;
        return "This is a helpful string";&#xD;
    }&#xD;
&#xD;
    // Note that transparency attributes do not go directly on properties.&#xD;
    // Instead, they go on the getters and setters (even if the getter and setter&#xD;
    // get the same attributes)&#xD;
    public virtual string LogLocation&#xD;
    {&#xD;
        get&#xD;
        {&#xD;
            return logLocation;&#xD;
        }&#xD;
&#xD;
        // This API is made critical because it sets sensitive data (the path to write to)&#xD;
        // which partial trust code should not be able to do.&#xD;
        [SecurityCritical]&#xD;
        // The previous LinkDemand is removed as the SecurityCritical attribute replaces it&#xD;
	//[FileIOPermissionAttribute(SecurityAction.LinkDemand, Unrestricted=true)]&#xD;
        set&#xD;
        {&#xD;
            logLocation = value;&#xD;
        }&#xD;
    }&#xD;
&#xD;
    // This API accesses a critical member (LogLocation) and, therefore, cannot be transparent&#xD;
    // However, the access is done in a limited, safe way and we expect transparent code&#xD;
    // should be able to call this API. Therefore, it is SecuritySafeCritical&#xD;
    [SecuritySafeCritical]&#xD;
    public virtual void SetLogLocation(int index)&#xD;
    {&#xD;
        switch (index)&#xD;
        {&#xD;
            case 1: &#xD;
                LogLocation = @"C:\temp\foo.txt";&#xD;
                break;&#xD;
            case 2:&#xD;
                LogLocation = @"D:\temp\foo.txt";&#xD;
                break;&#xD;
            case 3:&#xD;
                LogLocation = @"D:\repro\temp\foo.txt";&#xD;
                break;&#xD;
            default:&#xD;
                break;&#xD;
        }&#xD;
    }&#xD;
&#xD;
    // This API is potentially dangerous; it asserts which means it can&amp;#8217;t be transparent&#xD;
    // Because setting LogLocation is protected, however, partial trust code can safely&#xD;
    // call this API. In fact, it is intended that it is safe for partial trust code&#xD;
    // to call this method. Therefore, it is SecuritySafeCritical&#xD;
    [SecuritySafeCritical]&#xD;
    public virtual void DeleteLog()&#xD;
    {&#xD;
        FileIOPermission fp = new FileIOPermission(FileIOPermissionAccess.AllAccess, LogLocation);&#xD;
        fp.Assert();&#xD;
        if (File.Exists(LogLocation)) { File.Delete(LogLocation); }&#xD;
        SecurityPermission.RevertAll();&#xD;
    }&#xD;
&#xD;
    // TODO : Put other APIs (creating log, writing to log, etc) here&#xD;
}&#xD;
&#xD;
public class OtherLogging : Logging&#xD;
{&#xD;
    // The logic for attributing this method is complicated and it is an example of when&#xD;
    // SecAnnotate.exe can be very helpful. This API cannot be transparent because it &#xD;
    // calls a critical member (LogLocation). However, because it overrides a transparent&#xD;
    // method (Usage) it cannot be critical. Therefore, the only possible annotation here&#xD;
    // is SecuritySafeCritical and it is the author&amp;#8217;s responsibility to make sure that&#xD;
    // a malicious caller cannot abuse that access.&#xD;
    [SecuritySafeCritical]&#xD;
    public override string Usage()&#xD;
    {&#xD;
        LogLocation = null;&#xD;
        return "This is a different useful string";&#xD;
    }&#xD;
&#xD;
    // TODO : Put other APIs (creating log, writing to log, etc) here&#xD;
}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xD;
&lt;p&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;strong&gt;同步 CLR 和 Silverlight CoreCLR 安全系统&lt;/strong&gt;&lt;/p&gt;&#xD;
&lt;p&gt;尽管将 APTCA 和 v4 中的透明性合并似乎很复杂，但合并将最终在部分受信任调用方调用系统敏感资源时提供直接和有效的保护。此外，此变化较好地协调了桌面 CLR 和 Silverlight CoreCLR 安全系统。&lt;/p&gt;&#xD;
&lt;p&gt;SecAnnotate.exe 等 SDK 工具和 FxCop 规则（可以验证透明性）有助于简化迁移。V4 APTCA 程序集更加易于审核，您只要密切关注 SecuritySafeCritical API（和它们执行的 SecurityCritical 调用）即可对程序集的安全性满怀信心。&lt;/p&gt;&#xD;
&lt;p&gt;由于透明代码通常占程序集的 80-90% 甚至更多，因此同步合并可显著减少审核的工作量。如果您希望更加深入地了解透明性，请参阅 MSDN 文档以获得更全面的解释。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/1888998.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2010/11/26/1888998.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2010/11/08/1871528.html</id><title type="text">在VS2010 &amp;quot;Choose Toolbox Item&amp;quot; Dialog 中显示自定义控件</title><summary type="text">仅作记录：在VS2010 "Choose Toolbox Item" Dialog 中显示自定义控件，需要手动在注册表中增加一项：[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\【自定义项目名】]@="【Assembly所在的具体路径】"</summary><published>2010-11-08T02:15:00Z</published><updated>2010-11-08T02:15:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2010/11/08/1871528.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2010/11/08/1871528.html"/><content type="html">&lt;p&gt;仅作记录：&lt;/p&gt;&#xD;
&lt;p&gt;在VS2010 "Choose Toolbox Item" Dialog 中显示自定义控件，需要手动在注册表中增加一项：&lt;/p&gt;&#xD;
&lt;p&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\【自定义项目名】]&lt;br /&gt;@="【Assembly所在的具体路径】"&lt;br /&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/1871528.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2010/11/08/1871528.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2010/11/04/1868980.html</id><title type="text">笑话一则</title><summary type="text">今天收到一个笑话，和大家分享一下。某公司网管：妈的腾讯，脑子坏了？今天把老子忙死了，老板知道装了360上不了QQ，高兴坏了，现在强制公司所有电脑必须装360。。。。。把老子忙死了。。。</summary><published>2010-11-04T05:59:00Z</published><updated>2010-11-04T05:59:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2010/11/04/1868980.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2010/11/04/1868980.html"/><content type="html">&lt;p&gt;今天收到一个笑话，和大家分享一下。&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;span style="font-family: 宋体; color: #333333; font-size: 12pt"&gt;某公司网管：妈的腾讯，脑子坏了？今天把老子忙死了，老板知道装了&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 12pt"&gt;360&lt;/span&gt;&lt;span style="font-family: 宋体; color: #333333; font-size: 12pt"&gt;上不了&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 12pt"&gt;QQ&lt;/span&gt;&lt;span style="font-family: 宋体; color: #333333; font-size: 12pt"&gt;，高兴坏了，现在强制公司所有电脑必须装&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 12pt"&gt;360&lt;/span&gt;&lt;span style="font-family: 宋体; color: #333333; font-size: 12pt"&gt;。。。。。把老子忙死了。。。&lt;/span&gt;&lt;/p&gt;&#xD;
&lt;p&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/1868980.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2010/11/04/1868980.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/jacksonyin/archive/2010/10/12/1848485.html</id><title type="text">Assembly 的 Shadow-Copy 所在的folder</title><summary type="text">用VS2010开发，经常会发现最新Build的assembly不起做作用（特别是build的DesignTime的assembly的时候），或者在build的时候告诉你某个Assembly正在被使用。如果这个Assembly被打上strongname的话，那肯定是它存在Shadow-copy，IDE用了shadow-copy，而没用最新的build。所以只要把shadow-copy删掉就好了：Vi...</summary><published>2010-10-12T01:22:00Z</published><updated>2010-10-12T01:22:00Z</updated><author><name>Alen在西安</name><uri>http://www.cnblogs.com/jacksonyin/</uri></author><link rel="alternate" href="http://www.cnblogs.com/jacksonyin/archive/2010/10/12/1848485.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/jacksonyin/archive/2010/10/12/1848485.html"/><content type="html">&lt;p&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;用&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;VS2010&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;开发，经常会发现最新&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;Build&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;的&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;assembly&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;不起做作用（特别是&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;build&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;的&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;DesignTime&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;的&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;assembly&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;的时候），或者在&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;build&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;的时候告诉你某个&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;Assembly&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;正在&lt;/span&gt;&lt;span style="font-family: 'Arial','sans-serif'; color: #494949; font-size: 11.5pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-fareast-font-family: 宋体" lang="EN-US"&gt;被使用&lt;/span&gt;&lt;span style="font-family: 宋体; color: #494949; font-size: 11.5pt; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"&gt;。&lt;/span&gt;&lt;br /&gt;如果这个Assembly被打上strongname的话，那肯定是它存在Shadow-copy，IDE用了shadow-copy，而没用最新的build。&lt;/p&gt;&#xD;
&lt;p&gt;所以只要把shadow-copy删掉就好了：&lt;/p&gt;&#xD;
&lt;p&gt;Vista以前的OS，例如XP,2003等：&lt;br /&gt;rd /s /q %USERPROFILE%\Local Settings\Application Data\assembly&lt;/p&gt;&#xD;
&lt;p&gt;Vista以后：&lt;br /&gt;rd /s /q %USERPROFILE%\AppData\Local\assembly&lt;/p&gt;&lt;img src="http://www.cnblogs.com/jacksonyin/aggbug/1848485.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/jacksonyin/archive/2010/10/12/1848485.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry></feed>
