<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1391330880345771186</id><updated>2012-02-01T11:43:28.530-08:00</updated><category term='C# Programming'/><category term='Microsoft'/><category term='C# OOPs'/><category term='MSDN C#'/><category term='C# Samples'/><category term='C# Tutorials'/><category term='Biztalk Sever Tutorials'/><category term='MSDN Biztalk'/><category term='object oriented programing system'/><title type='text'>Software Technologies</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>97</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1602227179382165013</id><published>2011-05-24T03:23:00.001-07:00</published><updated>2011-05-24T03:23:28.440-07:00</updated><title type='text'>http://www.hitta.se/default.aspx</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.hitta.se/default.aspx"&gt;http://www.hitta.se/default.aspx&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1602227179382165013?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1602227179382165013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1602227179382165013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1602227179382165013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1602227179382165013'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/05/httpwwwhittasedefaultaspx.html' title='http://www.hitta.se/default.aspx'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-7807837023451683329</id><published>2011-04-20T23:22:00.003-07:00</published><updated>2011-04-20T23:22:24.989-07:00</updated><title type='text'>http://www.cemat.de/home</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.cemat.de/home"&gt;http://www.cemat.de/home&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-7807837023451683329?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/7807837023451683329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=7807837023451683329' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7807837023451683329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7807837023451683329'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/04/httpwwwcematdehome.html' title='http://www.cemat.de/home'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-6695526135725396762</id><published>2011-04-20T23:22:00.001-07:00</published><updated>2011-04-20T23:22:10.444-07:00</updated><title type='text'>http://www.ravas.com/</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.ravas.com/"&gt;http://www.ravas.com/&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-6695526135725396762?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/6695526135725396762/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=6695526135725396762' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6695526135725396762'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6695526135725396762'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/04/httpwwwravascom.html' title='http://www.ravas.com/'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-2575043654187754321</id><published>2011-04-20T23:21:00.000-07:00</published><updated>2011-04-20T23:21:24.995-07:00</updated><title type='text'>http://www.galbital.com/index.htm</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.galbital.com/index.htm"&gt;http://www.galbital.com/index.htm&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-2575043654187754321?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/2575043654187754321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=2575043654187754321' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2575043654187754321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2575043654187754321'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/04/httpwwwgalbitalcomindexhtm.html' title='http://www.galbital.com/index.htm'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1058107634192146580</id><published>2011-03-28T02:28:00.000-07:00</published><updated>2011-03-28T02:28:37.909-07:00</updated><title type='text'>aspnet_isapi.dll and aspnet_wp.exe</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc301898.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc301898.aspx&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1058107634192146580?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1058107634192146580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1058107634192146580' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1058107634192146580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1058107634192146580'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/03/aspnetisapidll-and-aspnetwpexe.html' title='aspnet_isapi.dll and aspnet_wp.exe'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-2177949317983986615</id><published>2011-02-24T03:53:00.001-08:00</published><updated>2011-02-24T03:53:39.001-08:00</updated><title type='text'>http://www.circuitstoday.com</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.circuitstoday.com/"&gt;http://www.circuitstoday.com/&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-2177949317983986615?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/2177949317983986615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=2177949317983986615' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2177949317983986615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2177949317983986615'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/02/httpwwwcircuitstodaycom.html' title='http://www.circuitstoday.com'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-3471992883057758794</id><published>2011-02-22T03:03:00.001-08:00</published><updated>2011-02-22T03:03:01.447-08:00</updated><title type='text'>http://www.amyuni.com/</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.amyuni.com/"&gt;http://www.amyuni.com/&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-3471992883057758794?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/3471992883057758794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=3471992883057758794' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3471992883057758794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3471992883057758794'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/02/httpwwwamyunicom.html' title='http://www.amyuni.com/'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-6447198212346853926</id><published>2011-02-22T03:01:00.001-08:00</published><updated>2011-02-22T03:01:16.649-08:00</updated><title type='text'>http://www.amyuni.com/en/developer/devtouch/pricing</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.amyuni.com/en/developer/devtouch/pricing"&gt;http://www.amyuni.com/en/developer/devtouch/pricing&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-6447198212346853926?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/6447198212346853926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=6447198212346853926' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6447198212346853926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6447198212346853926'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/02/httpwwwamyunicomendeveloperdevtouchpric.html' title='http://www.amyuni.com/en/developer/devtouch/pricing'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-2062065582763781631</id><published>2011-02-01T00:03:00.001-08:00</published><updated>2011-02-01T00:03:50.489-08:00</updated><title type='text'>ServiceHost Class</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div class="sectionblock" id="3b1b99f2-faed-4512-a3ad-5f2fdafe2ba0_c"&gt;&lt;a href="" id="remarksToggle" xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;/a&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx&lt;/a&gt;&lt;/div&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;Implements the host used by the service model programming model.&lt;/div&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;Use the &lt;span&gt;&lt;span class="selflink"&gt;ServiceHost&lt;/span&gt;&lt;/span&gt; class to configure and expose a service for use by client applications when you are not using Internet Information Services (IIS) or Windows Activation Services (WAS) to expose a service. Both IIS and WAS interact with a &lt;span&gt;&lt;span class="selflink"&gt;ServiceHost&lt;/span&gt;&lt;/span&gt; object on your behalf.&lt;/div&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;To expose a service for use by callers, requires a complete service description (represented by the &lt;span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicedescription.aspx"&gt;&lt;span style="color: #1364c4;"&gt;ServiceDescription&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; class). The &lt;span&gt;&lt;span class="selflink"&gt;ServiceHost&lt;/span&gt;&lt;/span&gt; class creates a &lt;span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicedescription.aspx"&gt;&lt;span style="color: #1364c4;"&gt;ServiceDescription&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; from the service type and configuration information and then uses that description to create &lt;span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.channeldispatcher.aspx"&gt;&lt;span style="color: #1364c4;"&gt;ChannelDispatcher&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; objects for each endpoint in the description. &lt;/div&gt;&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;Use a &lt;span&gt;&lt;span class="selflink"&gt;ServiceHost&lt;/span&gt;&lt;/span&gt; object to load a service, configure endpoints, apply security settings, and start listeners to handle incoming requests. &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-2062065582763781631?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/2062065582763781631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=2062065582763781631' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2062065582763781631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2062065582763781631'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/02/servicehost-class.html' title='ServiceHost Class'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-7925262160848722634</id><published>2011-01-24T02:21:00.001-08:00</published><updated>2011-01-24T02:21:23.649-08:00</updated><title type='text'>http://www.devexpress.com/</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://www.devexpress.com/"&gt;http://www.devexpress.com/&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-7925262160848722634?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/7925262160848722634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=7925262160848722634' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7925262160848722634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7925262160848722634'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/01/httpwwwdevexpresscom.html' title='http://www.devexpress.com/'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-9211743212726903885</id><published>2011-01-23T21:58:00.001-08:00</published><updated>2011-01-23T21:58:22.462-08:00</updated><title type='text'>aspnet_isapi.dll and aspnet_wp.exe</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc301898.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc301898.aspx&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-9211743212726903885?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/9211743212726903885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=9211743212726903885' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/9211743212726903885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/9211743212726903885'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/01/aspnetisapidll-and-aspnetwpexe.html' title='aspnet_isapi.dll and aspnet_wp.exe'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-238409483162391257</id><published>2011-01-19T02:28:00.001-08:00</published><updated>2011-01-19T02:28:10.040-08:00</updated><title type='text'>http://www.slb.com</title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-238409483162391257?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/238409483162391257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=238409483162391257' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/238409483162391257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/238409483162391257'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2011/01/httpwwwslbcom.html' title='http://www.slb.com'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-609257734071110461</id><published>2010-11-23T06:42:00.001-08:00</published><updated>2010-11-23T06:42:14.141-08:00</updated><title type='text'>http://scrumforteamsystem.com/</title><content type='html'>&lt;a href="http://scrumforteamsystem.com/"&gt;http://scrumforteamsystem.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-609257734071110461?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/609257734071110461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=609257734071110461' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/609257734071110461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/609257734071110461'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/11/httpscrumforteamsystemcom.html' title='http://scrumforteamsystem.com/'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4050735786492818580</id><published>2010-10-29T04:38:00.001-07:00</published><updated>2010-10-29T04:38:07.855-07:00</updated><title type='text'>http://www.elektor.com/</title><content type='html'>&lt;a href="http://www.elektor.com/"&gt;http://www.elektor.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4050735786492818580?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4050735786492818580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4050735786492818580' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4050735786492818580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4050735786492818580'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/10/httpwwwelektorcom.html' title='http://www.elektor.com/'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-6162306069929198512</id><published>2010-10-29T00:55:00.001-07:00</published><updated>2010-10-29T00:55:52.746-07:00</updated><title type='text'>http://www.matrixmultimedia.com</title><content type='html'>&lt;a href="http://www.matrixmultimedia.com/"&gt;http://www.matrixmultimedia.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-6162306069929198512?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/6162306069929198512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=6162306069929198512' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6162306069929198512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6162306069929198512'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/10/httpwwwmatrixmultimediacom.html' title='http://www.matrixmultimedia.com'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-7594093493945389764</id><published>2010-10-26T07:52:00.001-07:00</published><updated>2010-10-26T07:52:51.112-07:00</updated><title type='text'>.Net Framework</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_vttqn2eclRk/TMbrIXX0JLI/AAAAAAAAATM/jqdfAONjiDw/s1600/dotnet.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" nx="true" src="http://4.bp.blogspot.com/_vttqn2eclRk/TMbrIXX0JLI/AAAAAAAAATM/jqdfAONjiDw/s400/dotnet.jpg" width="341" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-7594093493945389764?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/7594093493945389764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=7594093493945389764' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7594093493945389764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7594093493945389764'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/10/net-framework.html' title='.Net Framework'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_vttqn2eclRk/TMbrIXX0JLI/AAAAAAAAATM/jqdfAONjiDw/s72-c/dotnet.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4279760622634994646</id><published>2010-07-20T06:03:00.000-07:00</published><updated>2010-07-20T06:03:43.655-07:00</updated><title type='text'>www.telerik.com</title><content type='html'>&lt;a href="http://www.telerik.com/team-productivity-tools/teampulse.aspx"&gt;http://www.telerik.com/team-productivity-tools/teampulse.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4279760622634994646?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4279760622634994646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4279760622634994646' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4279760622634994646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4279760622634994646'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/07/wwwtelerikcom.html' title='www.telerik.com'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-6254942592601465802</id><published>2010-07-01T06:16:00.000-07:00</published><updated>2010-07-01T06:16:37.514-07:00</updated><title type='text'>Hyper-V Server</title><content type='html'>&lt;strong&gt;Microsoft® Hyper-V™ Server 2008 R2&lt;/strong&gt; is a stand-alone product that provides a reliable and optimized virtualization solution enabling organizations to improve server utilization and reduce costs. Since Hyper-V Server is a dedicated stand-alone product, which contains only the Windows Hypervisor, Windows Server driver model and virtualization components, it provides a small footprint and minimal overhead. It easily plugs into customers’ existing IT environments, leveraging their existing patching, provisioning, management, support tools, processes, and skills. Some of the new key new features that are available in Microsoft Hyper-V Server 2008 R2 are live migration, cluster shared volume support and expanded processor and memory support for host systems.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;IT Pros can easily to leverage their existing knowledge and skills with Microsoft virtualization products, as well as the collective knowledge of the community, minimizing any learning curve. In addition, with Microsoft providing comprehensive support for Microsoft applications and heterogeneous guest operating systems, customers can virtualize with confidence and peace of mind.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;When to Use Hyper-V Server 2008 R2&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Customers can use Microsoft Hyper-V Server 2008 R2 for the following scenarios:&lt;br /&gt;&lt;br /&gt;Test and Development&lt;br /&gt;Server Consolidation&lt;br /&gt;Branch Office Consolidation&lt;br /&gt;Hosted Desktop Virtualization (VDI)&lt;br /&gt;&lt;br /&gt;Customers should use Windows Server 2008 R2 to get application failover capabilities or flexible and cost-effective virtualization rights (one free virtual instance for Standard Edition, four free virtual instances for Enterprise Editions, and unlimited virtual instances for Datacenter Edition with the purchase of a license of Windows Server 2008), and flexible and cost-effective virtualization rights.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Here is a list of the features in Hyper-V Server 2008 R2.&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_vttqn2eclRk/TCyVFiZbdsI/AAAAAAAAARs/B3qPZOvOdqc/s1600/123.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" rw="true" src="http://4.bp.blogspot.com/_vttqn2eclRk/TCyVFiZbdsI/AAAAAAAAARs/B3qPZOvOdqc/s400/123.jpg" width="367" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-6254942592601465802?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/6254942592601465802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=6254942592601465802' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6254942592601465802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6254942592601465802'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/07/hyper-v-server.html' title='Hyper-V Server'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_vttqn2eclRk/TCyVFiZbdsI/AAAAAAAAARs/B3qPZOvOdqc/s72-c/123.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1468661878527059496</id><published>2010-07-01T03:19:00.001-07:00</published><updated>2010-07-01T03:19:52.684-07:00</updated><title type='text'>BizTalk RFID Server</title><content type='html'>Comprehensive Device Management&lt;br /&gt;&lt;br /&gt;You now have comprehensive device management and solution deployment that spans mobile and fixed readers. With BizTalk Server RFID management capabilities you can manage multiple providers and devices end emulate devices. In addition, you are able to monitor and troubleshoot deployments using System Center Operations Manager. &lt;br /&gt;&lt;br /&gt;Capture Business Relevant Data&lt;br /&gt;&lt;br /&gt;Create, deploy and change business rules and event filtering to expose business relevant data and take the appropriate action based on incoming events. Through BizTalk’s Business Activity Monitoring (BAM) you can obtain end to end process visibility and analytics of RFID event flow during business process execution.&lt;br /&gt;&lt;br /&gt;Support for Industry Standards&lt;br /&gt;&lt;br /&gt;BizTalk Server RFID provides support for EPC Global standards like EPCIS, Tag Data Translator (TDT) and Low Level Reader Protocol.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_vttqn2eclRk/TCxrvP0VLCI/AAAAAAAAARk/5UhamlwkZgI/s1600/RFID-Value-Prop-lrg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="297" rw="true" src="http://4.bp.blogspot.com/_vttqn2eclRk/TCxrvP0VLCI/AAAAAAAAARk/5UhamlwkZgI/s400/RFID-Value-Prop-lrg.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1468661878527059496?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1468661878527059496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1468661878527059496' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1468661878527059496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1468661878527059496'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/07/biztalk-rfid-server.html' title='BizTalk RFID Server'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_vttqn2eclRk/TCxrvP0VLCI/AAAAAAAAARk/5UhamlwkZgI/s72-c/RFID-Value-Prop-lrg.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4918335194378972637</id><published>2010-07-01T03:17:00.000-07:00</published><updated>2010-07-01T03:17:50.039-07:00</updated><title type='text'>BizTalk RFID Mobile</title><content type='html'>Microsoft BizTalk RFID Mobile is an extension of the Microsoft BizTalk Server RFID platform to mobile devices. BizTalk RFID Mobile is an extensible platform for development, deployment and management of RFID, barcode and other sensor applications on mobile devices.&lt;br /&gt;&lt;br /&gt;Faster Time to Market &lt;br /&gt;&lt;br /&gt;Write applications once on Windows Mobile and Windows CE and run on multiple devices. By developing RFID applications on BizTalk’s RFID platform there is now a consistent application development experience across fixed and mobile readers. You will most likely want to integrate your data with existing business processes.&lt;br /&gt;&lt;br /&gt;Empower Workers to Do More&lt;br /&gt;&lt;br /&gt;With BizTalk RFID Mobile in the palm of their hands mobile workers will have access to information when and where they need it so that they can make decisions in real-time. Even if they don’t have network access, mobile workers will be able to perform critical operations and forward data to the server once there is a connection.&lt;br /&gt;&lt;br /&gt;Enhanced Business Intelligence&lt;br /&gt;&lt;br /&gt;New scenarios are now possible. You will now be able to capture more business relevant data and integrate that data with existing processes through BizTalk Server or replicate data to a SQL Server database. Bridge the gap between your core enterprise processes and your physical operations and assets.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_vttqn2eclRk/TCxrPG5DxqI/AAAAAAAAARc/yMjOcUKfP18/s1600/RFID-Arch-lrg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="257" rw="true" src="http://2.bp.blogspot.com/_vttqn2eclRk/TCxrPG5DxqI/AAAAAAAAARc/yMjOcUKfP18/s400/RFID-Arch-lrg.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4918335194378972637?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4918335194378972637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4918335194378972637' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4918335194378972637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4918335194378972637'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/07/biztalk-rfid-mobile.html' title='BizTalk RFID Mobile'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_vttqn2eclRk/TCxrPG5DxqI/AAAAAAAAARc/yMjOcUKfP18/s72-c/RFID-Arch-lrg.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-3099672947505553216</id><published>2010-07-01T03:14:00.001-07:00</published><updated>2010-07-01T03:15:06.659-07:00</updated><title type='text'>Microsoft BizTalk RFID</title><content type='html'>Microsoft BizTalk RFID is an innovative device management and event processing platform at the edge of the enterprise. It is designed to provide a scalable, extensible platform for development, deployment, and management of rich RFID and sensor solutions.&lt;br /&gt;&lt;br /&gt;Plug-and-play hardware eco-system with uniform device abstraction and management&lt;br /&gt;&lt;br /&gt;Robust, scalable, secure server platform for RFID solutions&lt;br /&gt;&lt;br /&gt;Extensive partner eco-system (ISVs/SI) for vertical solutions with low TCO, high ROI&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_vttqn2eclRk/TCxqeOzVSYI/AAAAAAAAARU/ESfq5uqPFzM/s1600/Logical-Overview-lrg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="291" rw="true" src="http://4.bp.blogspot.com/_vttqn2eclRk/TCxqeOzVSYI/AAAAAAAAARU/ESfq5uqPFzM/s400/Logical-Overview-lrg.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-3099672947505553216?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/3099672947505553216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=3099672947505553216' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3099672947505553216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3099672947505553216'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/07/microsoft-biztalk-rfid.html' title='Microsoft BizTalk RFID'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_vttqn2eclRk/TCxqeOzVSYI/AAAAAAAAARU/ESfq5uqPFzM/s72-c/Logical-Overview-lrg.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-5505419623029340686</id><published>2010-07-01T02:55:00.000-07:00</published><updated>2010-07-01T02:55:21.878-07:00</updated><title type='text'>BizTalk 2006 R2 RFID Demo</title><content type='html'>&lt;object codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" height="384" id="MediaPlayer" standby="Loading Windows Media Player components..." type="application/x-oleobject" width="512"&gt;  &lt;param name="filename" value="mms://wm.microsoft.com/ms/biztalk/RFID_Supply_Chain_Demo.wmv"&gt;&lt;param name="Showcontrols" value="True"&gt;&lt;param name="autoStart" value="True"&gt;&lt;embed type="application/x-mplayer2" src="mms://wm.microsoft.com/ms/biztalk/RFID_Supply_Chain_Demo.wmv" name="MediaPlayer" width=512 height=384&gt;&lt;/embed&gt;  &lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-5505419623029340686?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/5505419623029340686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=5505419623029340686' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5505419623029340686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5505419623029340686'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/07/biztalk-2006-r2-rfid-demo.html' title='BizTalk 2006 R2 RFID Demo'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-9204301096670929003</id><published>2010-07-01T01:03:00.000-07:00</published><updated>2010-07-01T01:03:37.070-07:00</updated><title type='text'>BizTalk Server and WCF Integration</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/bb973215.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb973215.aspx&lt;/a&gt; &lt;br /&gt;&lt;b&gt;Introduction&lt;/b&gt;&lt;br /&gt;With the November 2006 release of .NET Framework 3.0, the wait is finally over for software professionals. The core components of this managed code programming model â€“ Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) â€“ has revolutionized the way software is programmed.&lt;br /&gt;&lt;br /&gt;This article focuses on the different options available for communication between WCF and BTS06. While much of the discussion will also be applicable to BTS04, any discrepancies in implementation for BTS04 will be highlighted. &lt;br /&gt;&lt;br /&gt;There is a WCF Adapter for BTS06 is available on the CodePlex Web site. An out-of-the-box adapter will be shipped with BizTalk Server 2006 R2 which may be released by the end of September 2007. An overview of the R2 WCF Adapter's capabilities is available at the following blog post. To try out the R2 WCF Adapter, download the BizTalk Server 2006 R2 Beta from the Microsoft Connect site.&lt;br /&gt;&lt;br /&gt;However, you may need to integrate existing BizTalk-based applications with WCF to do the same. In this article we present various options to achieve interoperability in cases where upgrading to BizTalk Server 2006 R2 is not possible. The article merely outlines the approaches and does not deal with them in an exhaustive manner. Nor does it provide a benchmark to compare the approaches. You need to evaluate and choose one among the suggested techniques after taking into account the needs of your application. &lt;br /&gt;&lt;br /&gt;Note: If you are upgrading to BizTalk 2006 R2, then working with WCF Adapter will be ideal due to the ease of use, deployment and management it offers. &lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_vttqn2eclRk/TCxLyH3kx1I/AAAAAAAAARM/FtZqBg1KEUo/s1600/IC36977.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="262" rw="true" src="http://3.bp.blogspot.com/_vttqn2eclRk/TCxLyH3kx1I/AAAAAAAAARM/FtZqBg1KEUo/s400/IC36977.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-9204301096670929003?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/9204301096670929003/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=9204301096670929003' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/9204301096670929003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/9204301096670929003'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/07/biztalk-server-and-wcf-integration.html' title='BizTalk Server and WCF Integration'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_vttqn2eclRk/TCxLyH3kx1I/AAAAAAAAARM/FtZqBg1KEUo/s72-c/IC36977.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-5098290795596721555</id><published>2010-06-21T02:11:00.001-07:00</published><updated>2010-06-21T03:11:02.947-07:00</updated><title type='text'>ASP.NET 4 "Quick Hit" - Clean Web.Config Files</title><content type='html'>&lt;object id="MediaPlayer" width=512 height=384classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"&gt;  &lt;param name="filename" value="http://ecn.channel9.msdn.com/o9/ch9/1/3/8/6/5/5/TFS2010JPdemo003_2MB_ch9.wmv"&gt;&lt;param name="Showcontrols" value="True"&gt;&lt;param name="autoStart" value="True"&gt;&lt;embed type="application/x-mplayer2" src="http://ecn.channel9.msdn.com/o9/ch9/1/3/8/6/5/5/TFS2010JPdemo003_2MB_ch9.wmv" name="MediaPlayer" width=512 height=384&gt;&lt;/embed&gt;  &lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-5098290795596721555?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/5098290795596721555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=5098290795596721555' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5098290795596721555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5098290795596721555'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/06/aspnet-4-quick-hit-clean-webconfig.html' title='ASP.NET 4 &quot;Quick Hit&quot; - Clean Web.Config Files'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-2222027932231576739</id><published>2010-06-21T01:29:00.001-07:00</published><updated>2010-06-21T01:30:14.083-07:00</updated><title type='text'>Process Templates In TFS</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_vttqn2eclRk/TB8izoJV-9I/AAAAAAAAARE/P9UNG8ToEsE/s1600/scrum.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="295" ru="true" src="http://1.bp.blogspot.com/_vttqn2eclRk/TB8izoJV-9I/AAAAAAAAARE/P9UNG8ToEsE/s400/scrum.JPG" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-2222027932231576739?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/2222027932231576739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=2222027932231576739' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2222027932231576739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2222027932231576739'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/06/process-templates-in-tfs.html' title='Process Templates In TFS'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_vttqn2eclRk/TB8izoJV-9I/AAAAAAAAARE/P9UNG8ToEsE/s72-c/scrum.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1465395049074838197</id><published>2010-06-14T02:34:00.000-07:00</published><updated>2010-06-14T02:34:44.461-07:00</updated><title type='text'>Programming Best Practices</title><content type='html'>Belbinson Toby 14&amp;nbsp;Jun 2010&lt;br /&gt;Stockholm, Sweden&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Less Code Is Better&lt;br /&gt;&lt;br /&gt;The less code that you write, the less that you have to read, the less that you have to maintain, and usually the program will be simpler, and will often run faster.&lt;br /&gt;&lt;br /&gt;Rewrite It.&lt;br /&gt;&lt;br /&gt;It finally compiles! You just finished that big hairy part of the project, and it seems to work! Yeah, there are a few messy areas and some parts are a little hazy, but you got it done!&lt;br /&gt;&lt;br /&gt;...you just found a bug. It won't be too bad to fix, just go in and add another if-statement to detect for the special case, and you're good to go!&lt;br /&gt;&lt;br /&gt;If it's broken, don't fix it. Rewrite it.&lt;br /&gt;&lt;br /&gt;95% of the time you are better off rewriting all of the code. That little if-statement that you are adding, to fix an innocuous bug, may seem harmless, but it should be signalling disaster to you. It most likely means that your abstraction wasn't quite correct. So now you are making it a little bit harder to read. You are adding a little bit more code. It only takes a few minutes, and rewriting it would take hours or even days.&lt;br /&gt;&lt;br /&gt;In the long run, you would've been much better off not fixing it, but rewriting it. Now that you have found a few more bugs, and added a few more patches, and it's been a few months, the code is getting hairy. Now you are having a hard time being sure that the new code isn't making more bugs. And it's taking longer and longer to work with the program.&lt;br /&gt;&lt;br /&gt;If you would've just rewritten it to be correct, all these times, then you would have great code, solid abstractions, you would know the code inside and out, it would be readable and maintainable. After rewriting it a few times, the code just flows as well. It no longer takes as long to write it as it first did.&lt;br /&gt;&lt;br /&gt;Sure, sometimes you end up dumping the project or you didn't end up making things that much worse, by not rewriting it, but it's near impossible to guess when the 5% will be. Don't play that game. Just rewrite it.&lt;br /&gt;&lt;br /&gt;UPDATE: I've posted more of my thoughts on this in it's own essay.&lt;br /&gt;&lt;br /&gt;Code Is For People To Read&lt;br /&gt;&lt;br /&gt;Only as a side-effect is it for computers to run. The easier your code is to read, the better understanding you will have of it. You will have less bugs. It will be more maintainable.&lt;br /&gt;&lt;br /&gt;Sure, coding super fast, inline assembly makes you feel macho, but being macho doesn't help when CPU architecture changes, and you have to go back in, and decipher the mess you made.&lt;br /&gt;&lt;br /&gt;Correctness Wins&lt;br /&gt;&lt;br /&gt;Do it the right way. If you don't have enough time to do things right, then don't do them.&lt;br /&gt;&lt;br /&gt;It almost always costs more in the long run, to do things less than correctly. Most often the reason for incorrect code, is trying to do too much in too little time. This is the beginning of feature creep. You are entering the world of hazy abstractions.&lt;br /&gt;&lt;br /&gt;Do yourself a favor, stop coding.&lt;br /&gt;&lt;br /&gt;Stop Designing, Start Coding&lt;br /&gt;&lt;br /&gt;Instead of spending all of your time on the whiteboard, drawing up elaborate plans, start writing code. Yes, your code is going to suck. It is going to be a mess. But what's the rule when our code is a mess?&lt;br /&gt;&lt;br /&gt;Rewrite it.&lt;br /&gt;&lt;br /&gt;Your program will always be better off if you spend a day writing it 6 times, rather than designing it 6 times and writing it once. Writing code, and forcing yourself to rewrite it if it is incorrect, forces you to figure out the abstractions, and allows you to do deal with the real problems, instead of guessing what they will be.&lt;br /&gt;&lt;br /&gt;You aren't building a car. You can forget to hook up the brakes and still live.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1465395049074838197?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1465395049074838197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1465395049074838197' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1465395049074838197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1465395049074838197'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/06/programming-best-practices.html' title='Programming Best Practices'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-8667517945936112738</id><published>2010-06-09T02:43:00.000-07:00</published><updated>2010-06-09T02:43:29.238-07:00</updated><title type='text'>Fortran for .NET Language System</title><content type='html'>Fortran for .NET allows you to create applications for the Microsoft .NET Framework. Lahey and Fujitsu have combined advanced compiler technology with support for Forms designers and Web Services to enable Fortran organizations to develop .NET applications with Fortran as easily as with other Microsoft .NET languages. Fortran for .NET consists of a Fortran compiler and associated tools designed to help you create applications that run in the .NET Framework. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Fortran for .NET compiler &lt;br /&gt;Fortran for .NET language &lt;br /&gt;Visual Studio .NET integration &lt;br /&gt;Windows Forms &lt;br /&gt;ASP.NET Web Forms &lt;br /&gt;ADO.NET &lt;br /&gt;Fortran for .NET compiler options &lt;br /&gt;Restrictions on Fortran for .NET Code &lt;br /&gt;Hardware and software requirements for Enterprise and Academic Editions &lt;br /&gt;What can you do with Fortran for .NET and why would you want to? &lt;br /&gt;The Fortran for .NET language system is included in LF Fortran v7.1 Enterprise and Academic editions.&lt;br /&gt;--------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Fortran for .NET compiler&lt;br /&gt;&lt;br /&gt;Th Fortran for .NET compiler targets Microsoft's .NET Framework. The compiler does not directly generate processor dependent object code; rather, it generates Microsoft Intermediate Language (MSIL) code assemblies and code modules. The code in an assembly can be executed on any computer that supports an execution engine called the Common Language Runtime (CLR), such as the .NET Framework.&lt;br /&gt;&lt;br /&gt;The CLR does much more than provide the ability to operate on different operating systems, it also provides the basis for interoperability between different .NET languages, interlanguage debugging, versioning, and application deployment, among other things.&lt;br /&gt;&lt;br /&gt;Applications that are targeted for the CLR are called managed applications, or managed code. Managed applications are required to be type safe and to present standardized interfaces, so that interoperability and security requirements can be met. Because some older Fortran features (such as COMMON and EQUIVALENCE) can violate the CLRs rules for type safety and interfaces, certain restrictions had to be placed on .NET applications that do not allow 100% compatibility with Fortran standards. For details on restrictions, see Restrictions on Fortran for .NET Code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-8667517945936112738?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/8667517945936112738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=8667517945936112738' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8667517945936112738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8667517945936112738'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/06/fortran-for-net-language-system.html' title='Fortran for .NET Language System'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4277729823958482446</id><published>2010-05-19T04:08:00.000-07:00</published><updated>2010-05-19T04:19:33.009-07:00</updated><title type='text'>COBOL for Microsoft .NET Framework</title><content type='html'>&lt;strong&gt;Belbinson Toby&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Logica Pvt Ltd &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Stockholm, Sweden&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;May&amp;nbsp;2010&lt;br /&gt;&lt;br /&gt;Summary: Discusses why COBOL and .NET are strong partners and explains how Fujitsu COBOL has been integrated into the .NET Framework. (12 printed pages)&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Contents&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Why COBOL for .NET Makes Sense&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;What COBOL for .NET Looks Like&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Migrating COBOL Code to the .NET Framework&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;How COBOL for .NET is Implemented&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Getting Started with COBOL for .NET&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Microsoft’s .NET Framework not only enables the vision of companies sharing Web Services but also establishes a whole new development and execution environment for applications – whether on or off the Web. With components winning awards even before their full release, .NET is truly the latest and greatest happening in the application development world. COBOL, on the other hand, has been around almost from the beginning of business applications on computers and is unlikely to be mentioned by anyone talking about the “latest and greatest”. Why, then, have Microsoft and Fujitsu Software expended considerable effort in bringing these two technologies together? Has it been possible to integrate the “old” and “new” in a worthwhile manner? Does this combination of COBOL and .NET have anything to offer you, and how easy is it going to be for you to take advantage of those benefits?&lt;br /&gt;&lt;br /&gt;This paper aims to answer these questions for you firstly by laying out why the .NET Framework is attractive to business applications and COBOL programmers, and what COBOL has to offer to .NET. It will then give you a feel for COBOL for .NET by showing you what it looks like in different .NET technologies such as ASP.NET, Web Services and class sharing, explaining how you might use COBOL in each of these areas. It will give you an insight into what was done to make COBOL work in the .NET environment and conclude by describing how you can experience COBOL for .NET yourself.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Why COBOL for .NET Makes Sense&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;To understand why COBOL and .NET come together well, it is best to start with what COBOL has to offer. The reasons that COBOL runs over 70% of the world’s production business applications are that it has always provided:&lt;br /&gt;&lt;br /&gt;•Record-oriented data structures&lt;br /&gt;&lt;br /&gt;•Built-in business-oriented data types: alphanumeric, alphanumeric-edited, decimal, numeric-edited, and packed-decimal.&lt;br /&gt;&lt;br /&gt;•Simple control flow constructs&lt;br /&gt;&lt;br /&gt;•Readable and maintainable code&lt;br /&gt;&lt;br /&gt;Although often put down by speedy programmers, COBOL’s verbosity has been a big part of it providing readable and maintainable code. Maintainable code is a critical feature for business applications that can have life spans of many decades. Consider if you are in the position of committing your company’s core business processes to a programming language – do you want to select the “in” language of the moment which history has shown will be “out” in 10 years’ time, or do you want to select a language that has a 40 year track record, and which any programmer can understand?&lt;br /&gt;&lt;br /&gt;Another factor in favor of using COBOL for business logic, is that COBOL programmers typically have a lot of experience in supporting business needs. Their focus tends to be more on implementing the business functions rather than getting into the latest technology (just because it’s the latest).&lt;br /&gt;&lt;br /&gt;However, businesses still need to take advantage of the latest technology as this can often give them their competitive advantage or ensure that they aren’t disadvantaged relative to the competition. This, if anything, has been COBOL’ s weakness in the last decade – it has not always been able to take advantage of the latest technologies as the interfaces or architectures have not been accessible to COBOL.&lt;br /&gt;&lt;br /&gt;The .NET Framework changes all this. Web applications need a secure, managed environment in which to operate. In providing this Microsoft decided not just to create an environment that supported a single programming language, but to create an environment that was capable of supporting all programming languages, and to extend it so that it could support console, Windows GUI, and Web HTML styles of applications as well as the typically interface-less Web services. Figure 1 gives an overview of what the .NET Framework provides.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_vttqn2eclRk/S_PF7KTdbPI/AAAAAAAAAQg/H3CE9DEb3nc/s1600/vis-studio.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="250" src="http://3.bp.blogspot.com/_vttqn2eclRk/S_PF7KTdbPI/AAAAAAAAAQg/H3CE9DEb3nc/s400/vis-studio.jpg" width="400" wt="true" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This figure shows how Visual Studio .NET provides a common development environment for programming. Any language, such as COBOL, which is enabled for that development environment, can be developed with language-sensitive features including highlighting of text, project building and debugging. Then the code is compiled into a standard intermediate language called Microsoft Intermediate Language (MSIL) that is executed by the Common Language Run-time (CLR) in a secure, managed environment. MSIL is platform independent and is compiled to native code by the part of the run-time loading software. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One big benefit of the common execution environment is that its design is such that classes can be inherited from one language to another. .NET includes several frameworks, or libraries of classes, that any .NET language can use, including COBOL.&lt;br /&gt;&lt;br /&gt;The net result is that .NET offers an environment in which you develop in the language that makes most sense for the task.&lt;br /&gt;&lt;br /&gt;Now it should be obvious how COBOL can benefit from being a full player in the .NET framework. COBOL gets:&lt;br /&gt;&lt;br /&gt;•An award winning development environment (Visual Studio .NET) that is designed for creating .NET applications.&lt;br /&gt;&lt;br /&gt;•The ability to inherit the latest technologies from the framework classes.&lt;br /&gt;&lt;br /&gt;•The option to invoke code written in other languages in a seamless manner, whenever that code provides useful functionality.&lt;br /&gt;&lt;br /&gt;•The ability to support application needs wherever MSIL is supported - such as in ASP.NET pages and Web services.&lt;br /&gt;&lt;br /&gt;.NET benefits too by gaining:&lt;br /&gt;&lt;br /&gt;•The language that is best for many business logic implementations&lt;br /&gt;&lt;br /&gt;•The ability to execute the valuable business logic contained in around 200 billion lines of COBOL code worldwide (Gartner Group estimate)&lt;br /&gt;&lt;br /&gt;•The business expertise of hundreds of thousands of COBOL programmers&lt;br /&gt;&lt;br /&gt;Thus COBOL and .NET make a strong partnership; one that is worth exploring to see how you can exploit it to your company's advantage.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;What COBOL for .NET Looks Like&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To show you what COBOL looks like in the .NET Framework this paper presents three examples of COBOL code in different .NET areas:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;•Within an ASP.NET page, illustrating the provision of dynamic Web content using COBOL&lt;br /&gt;&lt;br /&gt;•As a Web Service, demonstrating how simple it can be to package existing modules as Web services.&lt;br /&gt;&lt;br /&gt;•Within the GUI Framework, showing how COBOL can inherit from other languages and how OO COBOL has been adapted to fit the object oriented .NET architecture.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ASP.NET (language="COBOL")&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;ASP.NET is the Microsoft successor to Active Server Pages (ASP), which were designed to deliver dynamic Web content. ASP faced a number of weaknesses in the areas of performance and programmability, and ASP.NET makes substantial improvements in those areas. Instead of being interpreted like ASP, ASP.NET compiles pages to native code. This change results in enormous performance benefits, with only a one-time cost to compile the page when it is first deployed. The other important side effect of the design choice (to compile instead of interpret) is that it opens the door for compiled languages to provide code in ASP.NET pages.&lt;br /&gt;&lt;br /&gt;ASP.NET Example 1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The following is a sample ASP.NET page written using COBOL that displays "Welcome to ASP.NET (now in COBOL!)" in increasing font sizes:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;%@ page language="COBOL" %&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script runat="server"&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;OBJECT.&lt;br /&gt;&lt;br /&gt;DATA DIVISION. &lt;br /&gt;&lt;br /&gt;WORKING-STORAGE SECTION.&lt;br /&gt;&lt;br /&gt;77 Font-Size PIC S9(9) COMP-5.&lt;br /&gt;&lt;br /&gt;END OBJECT.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;% PERFORM VARYING Font-Size FROM 1 BY 1 UNTIL Font-Size &amp;gt; 7 %&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;font size="&amp;lt;%=Font-Size%&amp;gt;"&amp;gt; Welcome to ASP.NET (now in COBOL!) &amp;lt;/font&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;br&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;% END-PERFORM. %&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The "&amp;lt;%@" characters introduce the directive that allow us to set the programming language for the page to COBOL. The &amp;lt;script&amp;gt; block allows us to introduce COBOL code that declares the FONT-SIZE variable and the characters "&amp;lt;%" allow us to introduce inline COBOL code to loop over the HTML that displays "Welcome to ASP.NET (now in COBOL!)"&lt;br /&gt;&lt;br /&gt;Fujitsu COBOL takes advantage of this important benefit by allowing COBOL programmers to embed COBOL code in ASP.NET pages.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4277729823958482446?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4277729823958482446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4277729823958482446' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4277729823958482446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4277729823958482446'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/05/cobol-for-microsoft-net-framework.html' title='COBOL for Microsoft .NET Framework'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_vttqn2eclRk/S_PF7KTdbPI/AAAAAAAAAQg/H3CE9DEb3nc/s72-c/vis-studio.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4290332744843824577</id><published>2010-04-24T03:23:00.000-07:00</published><updated>2010-04-24T03:23:09.394-07:00</updated><title type='text'>Dynamically Templated GridView with ITemplate Interface.</title><content type='html'>&lt;b&gt;Writing a class which implements ITemplate &lt;/b&gt;&lt;br /&gt;Here is the skeleton of class DynamicallyTemplatedGridViewHandler implementing ITemplate with a list of data members and methods.&lt;br /&gt;&lt;br /&gt;Listing 2&lt;br /&gt;&lt;br /&gt;public class DynamicallyTemplatedGridViewHandler : ITemplate&lt;br /&gt;{&lt;br /&gt;    ListItemType ItemType;&lt;br /&gt;    string FieldName;&lt;br /&gt;    string InfoType;&lt;br /&gt; &lt;br /&gt;    public DynamicallyTemplatedGridViewHandler(ListItemType Item_type,&lt;br /&gt;    string field_name, string control_type);&lt;br /&gt;    public void InstantiateIn(System.Web.UI.Control Container);&lt;br /&gt;    private void OnDataBinding(object sender, EventArgs e);&lt;br /&gt;}This class has three data members: &lt;br /&gt;&lt;br /&gt;    ListItemType ItemType;&lt;br /&gt;    string FieldName;&lt;br /&gt;    string InfoType;ItemType keeps the type of a list item type: Item, EditItem, Header, Footer, AlternatingItem, Pager, SelecetdItem or Separator. In this demo version we need only three of these; we need Header (For heading of each column), Item (for showing fields when GridView will be in normal mode) and EditItem (for showing fields when GridView will be in Edit mode). &lt;br /&gt;&lt;br /&gt;FieldName keeps the name of each template field that will be displayed in the header.&lt;br /&gt;&lt;br /&gt;InfoType keeps an indicator in string form for a type of information within a template field i.e. whether a template field has information of "Command" or "String" so that later data retrieval and data binding of that particular child control will be made accordingly. A "Command" (Edit, Delete, and Insert) requires instantiation in the Button control while he "String" requires a Label or TextBox.&lt;br /&gt;&lt;br /&gt;Now, coming to the member methods listed above, there is a constructer which simply sets the aforementioned data members with those passed as parameters.&lt;br /&gt;&lt;br /&gt;Listing 3&lt;br /&gt;&lt;br /&gt;public DynamicallyTemplatedGridViewHandler(ListItemType item_type, string field_name,&lt;br /&gt; string control_type)&lt;br /&gt;{&lt;br /&gt;  ItemType = item_type;&lt;br /&gt;  FieldName = field_name;&lt;br /&gt;  InfoType = info_type;&lt;br /&gt;}Here is the explanation of InstantiateIn the only method of ITemplate being implemented by our class DynamicallyTemplatedGridViewHandler.&lt;br /&gt;&lt;br /&gt;InstantiateIn&lt;br /&gt;&lt;br /&gt;InstantiateIn ensures that the list item type of each template is created in its appropriate control. For better understanding of functionality of this method see its name "InstantiateIn." It means "Instantiate Item In Literal/Label/TextBox/Button/." The choice will be according to the requirement. Like in the case of a Header, it is instantiated in Literal control as shown in this part of the implementation of InstantiateIn.&lt;br /&gt;&lt;br /&gt;InstantiateIn takes a "Container," a Control type object as a parameter. Container's control collection is filled with all controls in which items of each type are instantiated.  Its implementation in the current scenario is a little lengthy, yet it is quite easy as we have to do a similar type of job with each control; instantiate it, set its text property with FieldName and add it into Container's control collection. &lt;br /&gt;&lt;br /&gt;For example, below the code of InstantiateIn shows that if the ItemType is a Header, then it creates a literal object called header_literal. After making it bold, set the text property of header_literal with FieldName. Finally, add this control to the control collection of the Container control passed as parameter to InstantiateIn method. &lt;br /&gt;&lt;br /&gt;Similarly, we have to write instantiation code for ItemType if it is "Item" and "EditItem." In case the ItemType is "Item" (fields look when GridView is in normal mode), we need one more check inside it to see that InfoType tells whether the Item will be instantiated with a Button (Edit, Insert, and Delete) or Label. If InfoType is a Button then it creates three buttons for the aforementioned tasks. It is simple to do; create a button object, set its all properties accordingly, also add the button's click event handler and finally, add it into the control collection of the control (Container) passed as an argument.&lt;br /&gt;&lt;br /&gt;Listing 4&lt;br /&gt;&lt;br /&gt;public void InstantiateIn(System.Web.UI.Control Container)&lt;br /&gt;{&lt;br /&gt;  switch (ItemType)&lt;br /&gt;  {&lt;br /&gt;    case ListItemType.Header:&lt;br /&gt;      Literal header_ltrl = new Literal();&lt;br /&gt;      header_ltrl.Text = "&lt;b&gt;" + FieldName + "&lt;/b&gt;";&lt;br /&gt;      Container.Controls.Add(header_ltrl);&lt;br /&gt;      break;&lt;br /&gt;    case ListItemType.Item:&lt;br /&gt;      switch (InfoType)&lt;br /&gt;      {&lt;br /&gt;      case "Button":&lt;br /&gt;        ImageButton edit_button = new ImageButton();&lt;br /&gt;        edit_button.ID = "edit_button";&lt;br /&gt;        edit_button.ImageUrl = "~/images/edit.gif";&lt;br /&gt;        edit_button.CommandName = "Edit";&lt;br /&gt;        edit_button.Click += new ImageClickEventHandler(edit_button_Click);&lt;br /&gt;        edit_button.ToolTip = "Edit";&lt;br /&gt;        Container.Controls.Add(edit_button);&lt;br /&gt;/*Similarly, add button for delete just set its&lt;br /&gt; command to equal to "Delete." It is important to know when&lt;br /&gt; "insert" button is added, its CommandName is set to "Edit" like&lt;br /&gt; that of the "edi" button because we want the GridView to enter into&lt;br /&gt; Edit mode and this time we also want the text boxes for corresponding fields&lt;br /&gt; empty*/ ImageButton insert_button = new ImageButton();&lt;br /&gt;insert_button.ID = "insert_button";&lt;br /&gt;insert_button.ImageUrl = "~/images/insert.bmp";&lt;br /&gt;insert_button.CommandName = "Edit";&lt;br /&gt;insert_button.ToolTip = "Insert";&lt;br /&gt;insert_button.Click += new ImageClickEventHandler(insert_button_Click);&lt;br /&gt;Container.Controls.Add(insert_button);&lt;br /&gt;default:&lt;br /&gt;  Label field_lbl = new Label();&lt;br /&gt;  field_lbl.ID = FieldName;&lt;br /&gt;  field_lbl.Text = String.Empty;&lt;br /&gt;  field_lbl.DataBinding += new EventHandler(OnDataBinding);&lt;br /&gt;  Container.Controls.Add(field_lbl);&lt;br /&gt;  break;&lt;br /&gt;}&lt;br /&gt;break;&lt;br /&gt;case ListItemType.EditItem:&lt;br /&gt;  if (InfoType == "Button")&lt;br /&gt;  {&lt;br /&gt;    ImageButton update_button = new ImageButton();&lt;br /&gt;    update_button.ID = "update_button";&lt;br /&gt;    update_button.CommandName = "Update";&lt;br /&gt;    update_button.ImageUrl = "~/images/update.gif";&lt;br /&gt;    update_button.ToolTip = "Update";&lt;br /&gt;    update_button.OnClientClick =&lt;br /&gt;      "return confirm('Are you sure to update the record?')";&lt;br /&gt;    Container.Controls.Add(update_button);&lt;br /&gt; &lt;br /&gt;// Similarly, add a button for Cancel&lt;br /&gt; &lt;br /&gt;  }&lt;br /&gt;  else&lt;br /&gt;// if other key and non key fields then bind textboxes with texts&lt;br /&gt;  {&lt;br /&gt;    TextBox field_txtbox = new TextBox();&lt;br /&gt;    field_txtbox.ID = FieldName;&lt;br /&gt;    field_txtbox.Text = String.Empty;&lt;br /&gt;// if to update then bind the textboxes with coressponding field texts&lt;br /&gt;//otherwise for insert no need to bind it with text&lt;br /&gt; &lt;br /&gt;    if ((int)new Page().Session["InsertFlag"] == 0)&lt;br /&gt;      field_txtbox.DataBinding += new EventHandler(OnDataBinding);&lt;br /&gt;    Container.Controls.Add(field_txtbox);&lt;br /&gt; &lt;br /&gt;  }&lt;br /&gt;  break;&lt;br /&gt;}&lt;br /&gt;}When InfoType is not a Command it means we have to instantiate it with a label as in GridView's normal mode when each cell text of GridView's rows is displayed in label. Therefore, by default, control is instantiated with Label and is added into the Container. Since we have no more info types (other than command and string) then no further checks are required. We come to the outer check when ItemType is EditItem. Now, we need an inner check for info type (command or string). The template field will be instantiated in Button if the info type is Command; otherwise it requires TextBox for the cell text of edit item. &lt;br /&gt;&lt;br /&gt;It is important to know that the CommandName of insert_button is set to "Edit" just to take advantage of the Edit mode that provides text boxes for all editable items. If the these text boxes are emptied, they can be used for insertion instead of editing without dedicating an extra row for it. This is easy and handy as it becomes a better approach when it is not known in advance how many columns there are in GridView's data source. I have taken a session variable InsertFlag that is set to 0 and 1 for Edit and Inert operations respectively. &lt;br /&gt;&lt;br /&gt;Since we have to bind the labels in Item template and text boxes in EditItem template with corresponding cell values, the data binding event handler OnDataBinding of both label and text box populates the fields with cell values accordingly.&lt;br /&gt;&lt;br /&gt;And you might also want to know how text boxes for each field get emptied when Insert button is clicked. The solution is simple; do not bind them with a database and apply a check while adding the data binding event handler of text box. Do not call OnDataBinding if the insert button is clicked. &lt;br /&gt;&lt;br /&gt;Listing 5&lt;br /&gt;&lt;br /&gt;if ((int)new Page().Session["InsertFlag"] == 0)&lt;br /&gt;  field_txtbox.DataBinding += new EventHandler(OnDataBinding);DataBinding Event Handler     &lt;br /&gt;&lt;br /&gt;The implementation of the data binding event handler "OnDataBindin"' is simple. First, we get the "bound_value_object" that is returned by the static method Eval of DataBinder class which takes two parameters.  One is of type object called "data_item_container" (containing the DataItem that is assigned with sender control's NamingConatiner) and other is the string expression, FieldName. Once we get this bound_value_object, we assign its value (string) to the Text property of Label (if ItemType is Item; for normal mode) and TextBox (if ItemType is EditItem; for Edit mode). &lt;br /&gt;&lt;br /&gt;Listing 6&lt;br /&gt;&lt;br /&gt;private void OnDataBinding(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    object bound_value_obj = null;&lt;br /&gt;    Control ctrl = (Control)sender;&lt;br /&gt;    IDataItemContainer data_item_container = &lt;br /&gt;    (IDataItemContainer)ctrl.NamingContainer;&lt;br /&gt;    bound_value_obj = DataBinder.Eval(data_item_container.DataItem, FieldName);&lt;br /&gt;    switch (ItemType)&lt;br /&gt;    {&lt;br /&gt;       case ListItemType.Item:&lt;br /&gt;         Label field_ltrl = (Label)sender;&lt;br /&gt;         field_ltrl.Text = bound_value_obj.ToString();&lt;br /&gt;       break;&lt;br /&gt;       case ListItemType.EditItem:&lt;br /&gt;         TextBox field_txtbox = (TextBox)sender;&lt;br /&gt;         field_txtbox.Text = bound_value_obj.ToString();&lt;br /&gt;       break;&lt;br /&gt;    }&lt;br /&gt; }The implementation of ITemplate is complete, although I want to mention that there are some event handlers, "insert_button_Click" and "edit_button_Click" for Insert and Edit buttons respectively. They do nothing except the former sets the Session[InsertFlag] to 1 and the later sets it to 0.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4290332744843824577?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4290332744843824577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4290332744843824577' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4290332744843824577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4290332744843824577'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/04/dynamically-templated-gridview-with.html' title='Dynamically Templated GridView with ITemplate Interface.'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-5757463461267783866</id><published>2010-04-18T03:07:00.000-07:00</published><updated>2010-04-20T04:03:50.288-07:00</updated><title type='text'>Some Interesting  Codes</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&gt;&lt;br /&gt;/// Developer : Belbinson Toby &lt;br /&gt;/// &amp;lt;/summary&gt;&lt;br /&gt;namespace Class&lt;br /&gt;{ &lt;br /&gt;&lt;br /&gt;public interface IEmployee&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void Result();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public interface IDeveloper&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;void Result(); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public class Employee&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void Result()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Console.WriteLine("Employee");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class Developer : Employee, IEmployee, IDeveloper&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;void IEmployee.Result()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("IEmployee");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void IDeveloper.Result()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("IDeveloper");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public new void Result() &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Console.WriteLine("Developer");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class Program&lt;br /&gt;{&lt;br /&gt;static void Main(string[] args)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Developer objDeveloper = new Developer();&lt;br /&gt;objDeveloper.Result();// This will call Result Method in Developer Class&lt;br /&gt;&lt;br /&gt;Employee objEmployee = new Developer();&lt;br /&gt;objEmployee.Result();// This will call Result Method in Employee Class&lt;br /&gt;&lt;br /&gt;IEmployee objIe = new Developer();&lt;br /&gt;objIe.Result();// This will call Result Method in IEmployee Class&lt;br /&gt;&lt;br /&gt;IDeveloper objId = new Developer();&lt;br /&gt;objId.Result();// // This will call Result Method in IDeveloper Class&lt;br /&gt;&lt;br /&gt;Console.ReadLine(); &lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-5757463461267783866?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/5757463461267783866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=5757463461267783866' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5757463461267783866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5757463461267783866'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/04/using-system-using-system.html' title='Some Interesting  Codes'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-7825933548349608134</id><published>2010-04-07T06:33:00.000-07:00</published><updated>2010-04-07T06:33:11.564-07:00</updated><title type='text'>Extension Methods (C# Programming Guide)</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/bb383977.aspx"&gt;http://msdn.microsoft.com/en-us/library/bb383977.aspx&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type. For client code written in C# and Visual Basic, there is no apparent difference between calling an extension method and the methods that are actually defined in a type.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The most common extension methods are the LINQ standard query operators that add query functionality to the existing System.Collections.IEnumerable and System.Collections.Generic.IEnumerable&amp;lt;T&amp;gt; types. To use the standard query operators, first bring them into scope with a using System.Linq directive. Then any type that implements IEnumerable&amp;lt;T&amp;gt; appears to have instance methods such as GroupBy, OrderBy, Average, and so on. You can see these additional methods in IntelliSense statement completion when you type "dot" after an instance of an IEnumerable&amp;lt;T&amp;gt; type such as List&amp;lt;T&amp;gt; or Array. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The following example shows how to call the standard query operator OrderBy method on an array of integers. The expression in parentheses is a lambda expression. Many standard query operators take lambda expressions as parameters, but this is not a requirement for extension methods. For more information, see Lambda Expressions (C# Programming Guide).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-7825933548349608134?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/7825933548349608134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=7825933548349608134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7825933548349608134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7825933548349608134'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/04/extension-methods-c-programming-guide.html' title='Extension Methods (C# Programming Guide)'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-8415808505825193004</id><published>2010-04-07T06:31:00.000-07:00</published><updated>2010-04-07T06:31:53.782-07:00</updated><title type='text'>Constraints on Type Parameters (C# Programming Guide)</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/d5x73970(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/d5x73970(VS.80).aspx&lt;/a&gt; &lt;br /&gt;When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code attempts to instantiate your class with a type that is not allowed by a constraint, the result is a compile-time error. These restrictions are called constraints. Constraints are specified using the where contextual keyword. The following table lists the six types of constraints:&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-8415808505825193004?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/8415808505825193004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=8415808505825193004' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8415808505825193004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8415808505825193004'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/04/constraints-on-type-parameters-c.html' title='Constraints on Type Parameters (C# Programming Guide)'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4404415284814944230</id><published>2010-03-21T23:22:00.000-07:00</published><updated>2010-03-21T23:23:43.037-07:00</updated><title type='text'>Team Foundation Server...</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_vttqn2eclRk/S6cMZoPCpRI/AAAAAAAAAQI/SDOCsZ9CbLM/s1600-h/ms400682_ComplexTop(en-us,VS_90).png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="362" src="http://2.bp.blogspot.com/_vttqn2eclRk/S6cMZoPCpRI/AAAAAAAAAQI/SDOCsZ9CbLM/s400/ms400682_ComplexTop(en-us,VS_90).png" vt="true" width="400" /&gt;&lt;/a&gt;&lt;a href="http://4.bp.blogspot.com/_vttqn2eclRk/S6cMXKJKdvI/AAAAAAAAAQA/iv7WbXlZHhs/s1600-h/tfs.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="368" src="http://4.bp.blogspot.com/_vttqn2eclRk/S6cMXKJKdvI/AAAAAAAAAQA/iv7WbXlZHhs/s400/tfs.gif" vt="true" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4404415284814944230?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4404415284814944230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4404415284814944230' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4404415284814944230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4404415284814944230'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/team-foundation-server_21.html' title='Team Foundation Server...'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_vttqn2eclRk/S6cMZoPCpRI/AAAAAAAAAQI/SDOCsZ9CbLM/s72-c/ms400682_ComplexTop(en-us,VS_90).png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-6133261452013707363</id><published>2010-03-21T23:14:00.001-07:00</published><updated>2010-03-21T23:14:54.269-07:00</updated><title type='text'>Team Foundation Server...</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_vttqn2eclRk/S6cKwBuGnlI/AAAAAAAAAP4/KXeLQnanPnI/s1600-h/tfsOverview.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="364" src="http://4.bp.blogspot.com/_vttqn2eclRk/S6cKwBuGnlI/AAAAAAAAAP4/KXeLQnanPnI/s640/tfsOverview.png" vt="true" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-6133261452013707363?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/6133261452013707363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=6133261452013707363' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6133261452013707363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6133261452013707363'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/team-foundation-server.html' title='Team Foundation Server...'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_vttqn2eclRk/S6cKwBuGnlI/AAAAAAAAAP4/KXeLQnanPnI/s72-c/tfsOverview.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-5166805535664554091</id><published>2010-03-15T08:49:00.000-07:00</published><updated>2010-03-21T22:52:05.287-07:00</updated><title type='text'>Agile Scrum Methodology</title><content type='html'>&lt;div class="separator" style="border-bottom: medium none; border-left: medium none; border-right: medium none; border-top: medium none; clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_vttqn2eclRk/S6cFUnpwOPI/AAAAAAAAAPo/2x3TPMoaLDQ/s1600-h/Scrum%2520Overview%2520Diagram.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://4.bp.blogspot.com/_vttqn2eclRk/S6cFUnpwOPI/AAAAAAAAAPo/2x3TPMoaLDQ/s640/Scrum%2520Overview%2520Diagram.png" vt="true" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-5166805535664554091?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/5166805535664554091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=5166805535664554091' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5166805535664554091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5166805535664554091'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/agile-scrum-methodology.html' title='Agile Scrum Methodology'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_vttqn2eclRk/S6cFUnpwOPI/AAAAAAAAAPo/2x3TPMoaLDQ/s72-c/Scrum%2520Overview%2520Diagram.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-2658439287637759816</id><published>2010-03-09T02:55:00.001-08:00</published><updated>2010-03-09T02:55:33.547-08:00</updated><title type='text'>Use .NET's BackgroundWorker to Keep ASP.NET Cache in Sync with a SQL Server Database</title><content type='html'>&lt;strong&gt;&lt;span style="color: #f9cb9c;"&gt;Introduction&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;Storing frequently accessed database data, like lookup lists, in ASP.NET’s cache is a great way to optimize a web application’s performance. But anytime you store database data in ASP.NET’s cache, you have to provide a way to update that cache. This ensures changes made in the database make it into the web application’s cache. This is handled using either notifications or polling. &lt;br /&gt;&lt;br /&gt;Notifications are possible when using SQL Server 2005 with notification services and .NET’s SqlDependency object from the System.Data.SqlClient namespace. But notification services aren’t available in SQL Server 2008 or other databases. Even if you are using SQL Server 2005, employing this technology requires more server configuration and therefore complicates deployment. &lt;br /&gt;&lt;br /&gt;Polling is often handled by setting an expiration of the cached item at some time interval such as hourly. That way the cache holds the data for an hour and then automatically dumps it. Then when the data is requested and the cache is empty, the data is read from the database and placed back into the cache. This approach works fairly well, but with two drawbacks. First, it requires the cache be refreshed even when it is not needed. Second, it runs on the same thread as the request so some unlucky user has to wait a little longer for their request to return while the data is read from the database and stored in the cache. &lt;br /&gt;&lt;br /&gt;The BackgroundWorker object in .NET enables a better solution. When the web application starts, it spins off a background thread, and passes to it the application’s HttpContext object, enabling the thread, access to the application’s cache. When the web application ends, it stops the background thread. The background thread runs a continuous loop of sleeping for some time interval, and then polls the database to see if data has changed during that interval. If data has changed, the cache is refreshed. This solution is highly efficient because it runs on a background thread and refreshes the cache only when needed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-2658439287637759816?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/2658439287637759816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=2658439287637759816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2658439287637759816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2658439287637759816'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/use-nets-backgroundworker-to-keep.html' title='Use .NET&apos;s BackgroundWorker to Keep ASP.NET Cache in Sync with a SQL Server Database'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-5519318198231680508</id><published>2010-03-09T02:21:00.001-08:00</published><updated>2010-03-09T02:21:33.918-08:00</updated><title type='text'>Writing CLS-Compliant Code</title><content type='html'>&lt;div&gt;&lt;input type="hidden" name="flag" id="flag" value="false" /&gt;&lt;br /&gt;&lt;input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /&gt;&lt;br /&gt;&lt;input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /&gt;&lt;br /&gt;&lt;input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUBMGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFHmN0bDAwJGN0bDA5JGN0bDAwJFNlYXJjaEJ1dHRvbqIelUzuFt6BBhkCtYIR/9CnSPa5" /&gt;&lt;br /&gt;&lt;/div&gt; &lt;br /&gt;&lt;script type="text/javascript"&gt; //&lt;![CDATA[var theForm = document.forms['aspnetForm'];if (!theForm) {    theForm = document.aspnetForm;}function __doPostBack(eventTarget, eventArgument) {    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {        theForm.__EVENTTARGET.value = eventTarget;        theForm.__EVENTARGUMENT.value = eventArgument;        theForm.submit();    }}//]]&gt;&lt;/script&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;script src="/WebResource.axd?d=y48MEe_dRk_v_rnD4dSyAA2&amp;amp;t=633802380069218315" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;script type="text/javascript"&gt; //&lt;![CDATA[var CurUserId="AxUFAAAAAAC4CAAArPjKfddLESg9gn2RbSbJCw!!";var ClientURL="http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary(d%3ddefault)%2fbhc3fa7f(l%3den-us%2cv%3dVS.90).aspx";var maxRating=5;var RatingObjId="ctl00_ib1_Flyout_Rating1";var tbCommentsId="ctl00_ib1_Flyout_tbComments";var PageId="bhc3fa7f";var pageTag="contentRatingbhc3fa7fVS.90en-us";var sendBtnId="ctl00_ib1_Flyout_btnSend";var curRating="3";var contentRated=false;var RatingTooltipText="Click a star and provide feedback";var RatedTooltipText="You have already rated this content. Thank you for your feedback.";var userIPAddress="87.255.50.71";var MtpsPageDirection="ltr";var RatingFlyoutID="ctl00_ib1_Flyout";var Rating_Device="default";var CCI_DeleteConfirmationText="Are you sure you want to delete?";function wkAddNewItemClick(){CCE_EditAnnotation(-1);};var CCS_AddLinkID="ctl00_WikiContent_Add";var CCS_User="";var CCS_ContentUrl="http://msdn.microsoft.com/en-us/library/bhc3fa7f.aspx";//]]&gt;&lt;/script&gt;&lt;br /&gt; &lt;br /&gt;&lt;script src="http://i2.msdn.microsoft.com/Platform/cjs/jquery-1.2.6-bn20100217.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;&lt;script src="http://i2.msdn.microsoft.com/Platform/cjs/Silverlight-bn20100217.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt; //&lt;![CDATA[var wt_nvr_ru = "WT_NVR_RU";var wt_fpcdom = ".microsoft.com";var wt_domlist = "msdn.microsoft.com";var wt_pathlist = "";var wt_paramlist = "DCSext.mtps_devcenter";var wt_siteid = "MSDN";var gDomain="m.webtrends.com";var gDcsId="dcsmgru7m99k7mqmgrhudo0k8_8c6m";var gFpc="WT_FPC";/*&lt;![CDATA[*/if(document.cookie.indexOf(gFpc+"=")==-1){document.write("&lt;scr"+"ipt type='text/javascript' src='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'&gt;&lt;\/scr"+"ipt&gt;");}/*]]&gt;*/var detectedLocale = 'en-us';var wtsp="msdnlib_devtools_lang";var gTrackEvents = 0;var omni_guid='dfc9a8ad-46fc-47e1-8202-9cb8d91c351d';//]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;SCRIPT LANGUAGE='JavaScript' SRC='http://i2.msdn.microsoft.com/platform/Controls/Omniture/resources/MSDN/omni_rsid_msdn-bn20100217.js'&gt;&lt;/SCRIPT&gt;&lt;noscript&gt;&lt;a href='http://www.omniture.com' title='Web Analytics'&gt;&lt;img src='http://msstonojsmsdn.112.2o7.net/b/ss/msstonojsmsdn/1/H.20.2--NS/0'  height='1' width='1' border='0' alt='' /&gt;&lt;/a&gt;&lt;/noscript&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt; //&lt;![CDATA[var CCT_Browse="Browse other topics containing this tag";var CCT_Remove="Remove the tag from this topic";var CCT_NoTags="No tags entered";var CCT_Error="An error has occurred";var CCT_BugTag="contentbug";var CCE_ErrSameContent = "Content has not changed";var CCE_ErrEmptyTitle = "Title can not be empty";var CCE_ErrEmptyContent = "Content cannot be empty";var CCE_ErrTitleTooLong = "Title is limited to 100 characters";var CCE_ErrContentTooLong = "Content is limited to 50,000 characters";var CCE_ErrServerError = "Error occurred while saving your data.";var CCE_IsEditing=false;var CCE_IsTaggingEnabled=true;var CCE_TitleMaxLen=100;var CCE_ContentMaxLen=50000;var CCE_UpdateText="Please Wait";//]]&gt;&lt;/script&gt;&lt;br /&gt; &lt;br /&gt;&lt;script src="http://i2.msdn.microsoft.com/platform/cjs/extract/compositejscript2.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;&lt;div&gt; &lt;br /&gt; &lt;input type="hidden" name="__PREVIOUSPAGE" id="__PREVIOUSPAGE" value="G5fvCphs1NIsPKcmp_iaVcrm3UQbfBA8H9_nRwUj-g41" /&gt;&lt;br /&gt;&lt;/div&gt;  &lt;script type="text/javascript"&gt; //&lt;![CDATA[Sys.WebForms.PageRequestManager._initialize('ctl00$ScriptManager1', document.getElementById('aspnetForm'));Sys.WebForms.PageRequestManager.getInstance()._updateControls(['fctl00$WikiContent$ctl00$ItemUpdatePanel'], [], [], 90);//]]&gt;&lt;/script&gt;&lt;br /&gt; &lt;br /&gt;   &lt;br /&gt;  &lt;div id="rheader"&gt;    &lt;br /&gt; &lt;br /&gt;&lt;div class="mastheadfontbase"&gt;  &lt;div&gt;  &lt;div class="GlobalBar"&gt;   &lt;div class="Teaser"&gt;    &lt;br /&gt; &lt;br /&gt;&lt;span id="ticklerWrapper" &gt;&lt;br /&gt;&lt;a id="ctl00_ctl09_Tickler1_InstallLink" class="slLink" href="http://clk.atdmt.com/MRT/go/141489558/direct/01/" onclick="javascript:Track('ctl00_ctl09_Tickler1|_InstallLink',this);"&gt;Upgrade your Internet Experience&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;   &lt;/div&gt;   &lt;div class="GlobalBarRight"&gt;     &lt;div class="LocaleFlyout"&gt;      &lt;div class="LocaleManagementFlyoutStatic" style="position:relative;" id="ctl00_ctl09_LocaleManagement_ctl00"&gt;&lt;a class="LocaleManagementFlyoutStaticLink" href="javascript:void(0)"&gt;United States - English&amp;nbsp;&lt;/a&gt;&lt;img class="LocaleManagementFlyoutPopArrow LibC_popdownarrow" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" alt="Dropdown Arrow" style="height:4px;width:7px;border-width:0px;" /&gt;&lt;div id="ctl00_ctl09_LocaleManagement_ctl00_Popup" class="LocaleManagementFlyoutPopup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;  &lt;table border="0" style="width:175px;"&gt;   &lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl05','')"&gt;Argentina (Español)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl06','')"&gt;Australia (English)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl07','')"&gt;Brasil (Português)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl08','')"&gt;Canada (English)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl09','')"&gt;Canada (Français)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl10','')"&gt;中国 (简体中文)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl11','')"&gt;Colombia (Español)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl12','')"&gt;Deutschland (Deutsch)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl13','')"&gt;España (Español)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl14','')"&gt;France (Français)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl15','')"&gt;India (English)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl16','')"&gt;Italia (Italiano)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl17','')"&gt;日本 (日本語)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl18','')"&gt;México (Español)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl19','')"&gt;Perú (Español)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl20','')"&gt;Россия (Pусский)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl21','')"&gt;United Kingdom (English)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="javascript:__doPostBack('ctl00$ctl09$LocaleManagement$ctl00$ctl22','')"&gt;United States (English)&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td class="LocaleManagementFlyoutPopupHr"&gt;&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;    &lt;td&gt;&lt;a href="/en-us/ms376822.aspx"&gt;More...&lt;/a&gt;&lt;/td&gt;   &lt;/tr&gt;  &lt;/table&gt;&lt;/div&gt;&lt;div id="ctl00_ctl09_LocaleManagement_ctl00_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;&lt;/div&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;      &lt;/div&gt;      &lt;div class="SiteMap"&gt;      &lt;a id="ctl00_ctl09_MSFT_Site" title="Microsoft.com" class="SiteMapLink" href="http://www.microsoft.com"&gt;Microsoft.com&lt;/a&gt;&lt;br /&gt;     &lt;/div&gt;     &lt;div class="PassportScarab"&gt;      &lt;span id="ctl00_ctl09_UserRecognitionFlyout_lbwelcom" class="UserRecognitionStaticText"&gt;Welcome&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &amp;nbsp;&lt;br /&gt;    &lt;br /&gt;&lt;script language="Javascript" type="text/javascript"&gt; &lt;!--function deleteCookie() {    document.cookie= "A=;path=/;domain=microsoft.com;expires=Thu, 01-Jan-1970 00:00:01 GMT";    document.cookie= "msdn=;path=/;domain=microsoft.com;expires=Thu, 01-Jan-1970 00:00:01 GMT";    }//--&gt;&lt;/script&gt;&lt;br /&gt;&lt;a onclick="javascript:deleteCookie();window.location.href='http://msdn.microsoft.com/en-us/library/bhc3fa7f.aspx';return false;" id="ctl00_ctl09_UserRecognitionFlyout_loginView_RemoveAnonymousProfile_DeleteProfileCookieButton" class="UserRecognitionOtherLink" href="javascript:__doPostBack('ctl00$ctl09$UserRecognitionFlyout$loginView$RemoveAnonymousProfile$DeleteProfileCookieButton','')"&gt;Not Belbinson? &lt;/a&gt;&lt;a id="ctl00_ctl09_UserRecognitionFlyout_loginView_RemoveAnonymousProfile_ctl00" href="RemoveAnonymousProfile" onclick="javascript:Track('ctl00_ctl09_UserRecognitionFlyout_loginView_RemoveAnonymousProfile|_ctl00',this);"&gt;&lt;/a&gt;&lt;br /&gt;    &lt;br /&gt;  &lt;br /&gt;&lt;a id="idPPScarab" href="http://login.live.com/login.srf?wa=wsignin1.0&amp;amp;rpsnv=11&amp;amp;ct=1268120691&amp;amp;rver=6.0.5276.0&amp;amp;wp=MCLBI&amp;amp;wlcxt=msdn%24msdn%24msdn&amp;amp;wreply=http:%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fbhc3fa7f.aspx&amp;amp;lc=1033&amp;amp;id=254354" &gt;&lt;span id="idPPScarabSIT" class="MTPS_GlobalToolbarLinks_msdn"&gt;Sign in&lt;/span&gt;&lt;/a&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;     &lt;/div&gt;     &lt;br /&gt;     &lt;br /&gt;    &lt;/div&gt;  &lt;/div&gt; &lt;/div&gt; &lt;div class="classicTopNav"&gt;     &lt;div class="ThinNavBox"&gt;  &lt;a href="/en-us/default.aspx" id="ctl00_ctl09_brandlink"&gt;&lt;div id="ctl00_ctl09_BrandLogo" class="BrandLogo"&gt; &lt;br /&gt;&lt;/div&gt;&lt;/a&gt;&lt;br /&gt;  &lt;div class="Search"&gt;&lt;div id="ctl00_ctl09_ctl00_SearchBox" class="SearchBox"&gt;    &lt;input name="ctl00$ctl09$ctl00$SearchTextBox" type="text" id="ctl00_ctl09_ctl00_SearchTextBox" title="Search MSDN" class="TextBoxSearch" /&gt;&lt;br /&gt;    &lt;input type="image" name="ctl00$ctl09$ctl00$SearchButton" id="ctl00_ctl09_ctl00_SearchButton" title="Click here to search" class="SearchButton" alt="Click here to search" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&lt;br /&gt;    &lt;span class="Bing"&gt;&lt;/span&gt;&lt;br /&gt;&lt;script type="text/javascript" defer="defer" src="http://i3.services.social.microsoft.com/search/Widgets/SearchBox.jss?boxid=ctl00_ctl09_ctl00_SearchTextBox&amp;btnid=ctl00_ctl09_ctl00_SearchButton&amp;brand=MSDN&amp;loc=en-us" id="mscom.srch.searchBox"&gt;&lt;/script&gt;&lt;/div&gt;&lt;/div&gt;  &lt;div class="evergreenLinks"&gt;     &lt;br /&gt;      &lt;br /&gt;     &lt;br /&gt;        &lt;a id="ctl00_ctl09_eventlink"&gt;&lt;div id="ctl00_ctl09_EventLogo" class="EventLogo"&gt; &lt;br /&gt;&lt;/div&gt;&lt;/a&gt;&lt;br /&gt;     &lt;/div&gt;     &lt;br /&gt;       &lt;br /&gt; &lt;/div&gt;     &lt;div class="Clear"&gt;&lt;/div&gt;        &lt;br /&gt; &lt;br /&gt; &lt;div class="NavigationBox"&gt;     &lt;div id="ctl00_ctl09_tabs_CenterTitle" class="HeaderTitle"&gt;Visual Studio Developer Center&lt;/div&gt;  &lt;div class="Sponsor"&gt;    &lt;br /&gt;  &lt;/div&gt;  &lt;div class="ClearLeft"&gt;&lt;/div&gt;        &lt;div class="leftcap"&gt;&lt;/div&gt;        &lt;div class="internav"&gt;         &lt;div id="ctl00_ctl09_tabs_manTabsHolder"&gt;&lt;a id="ctl00_ctl09_tabs_ctl01" href="http://msdn.microsoft.com/en-us/vstudio/default.aspx" onclick="javascript:Track('|TabStrip Link|ctl00_ctl09_tabs_ctl00|ctl00_ctl09_tabs_ctl01',this);"&gt;Home&lt;/a&gt;&lt;a id="ctl00_ctl09_tabs_ctl03" class="active" href="http://msdn.microsoft.com/en-us/library/aa187916.aspx" onclick="javascript:Track('|TabStrip Link|ctl00_ctl09_tabs_ctl02|ctl00_ctl09_tabs_ctl03',this);"&gt;Library&lt;/a&gt;&lt;a id="ctl00_ctl09_tabs_ctl05" href="http://visualstudiogallery.msdn.microsoft.com/en-us/" onclick="javascript:Track('|TabStrip Link|ctl00_ctl09_tabs_ctl04|ctl00_ctl09_tabs_ctl05',this);"&gt;Gallery&lt;/a&gt;&lt;a id="ctl00_ctl09_tabs_ctl07" href="http://msdn.microsoft.com/en-us/vstudio/cc136611.aspx" onclick="javascript:Track('|TabStrip Link|ctl00_ctl09_tabs_ctl06|ctl00_ctl09_tabs_ctl07',this);"&gt;Learn&lt;/a&gt;&lt;a id="ctl00_ctl09_tabs_ctl09" href="http://msdn.microsoft.com/en-us/vstudio/bb984878.aspx" onclick="javascript:Track('|TabStrip Link|ctl00_ctl09_tabs_ctl08|ctl00_ctl09_tabs_ctl09',this);"&gt;Downloads&lt;/a&gt;&lt;a id="ctl00_ctl09_tabs_ctl11" href="http://msdn.microsoft.com/en-us/vstudio/cc136615.aspx" onclick="javascript:Track('|TabStrip Link|ctl00_ctl09_tabs_ctl10|ctl00_ctl09_tabs_ctl11',this);"&gt;Support&lt;/a&gt;&lt;a id="ctl00_ctl09_tabs_ctl13" href="http://msdn.microsoft.com/en-us/vstudio/cc136616.aspx" onclick="javascript:Track('|TabStrip Link|ctl00_ctl09_tabs_ctl12|ctl00_ctl09_tabs_ctl13',this);"&gt;Community&lt;/a&gt;&lt;a id="ctl00_ctl09_tabs_ctl15" href="http://social.msdn.microsoft.com/Forums/en-US/category/visualstudio" onclick="javascript:Track('|TabStrip Link|ctl00_ctl09_tabs_ctl14|ctl00_ctl09_tabs_ctl15',this);"&gt;Forums&lt;/a&gt;&lt;/div&gt;        &lt;/div&gt;        &lt;br /&gt; &lt;br /&gt;&lt;div id="ctl00_ctl09_tabs_LwViewSwitcher1_Panel1" class="LWVS_Loband"&gt; &lt;br /&gt;&lt;a id="ctl00_ctl09_tabs_LwViewSwitcher1_ClassicLink" tabindex="201" class="LWVS_DisabledLink" onclick="SetViewCookie('classic')"&gt;Classic&lt;/a&gt;&amp;nbsp | &amp;nbsp &lt;a href="http://msdn.microsoft.com/en-us/library/bhc3fa7f.aspx" id="ctl00_ctl09_tabs_LwViewSwitcher1_LightweightLink" tabindex="202" class="LWVS_Link" onclick="SetViewCookie('lightweight')"&gt;Lightweight Beta&lt;/a&gt;&amp;nbsp | &amp;nbsp &lt;a href="http://msdn.microsoft.com/en-us/library/bhc3fa7f.aspx" id="ctl00_ctl09_tabs_LwViewSwitcher1_LobandLink" tabindex="203" class="LWVS_Link" onclick="SetViewCookie('loband')"&gt;ScriptFree&lt;/a&gt;&lt;br /&gt;&lt;/div&gt; &lt;br /&gt; &lt;br /&gt;        &lt;div class="rightcap"&gt;&lt;/div&gt; &lt;/div&gt; &lt;br /&gt; &lt;div class="Clear"&gt;&lt;/div&gt; &lt;div id="ctl00_ctl09_tabs_LocalNavigation" class="LocalNavigation" style="height:2px;"&gt;     &lt;br /&gt; &lt;img class="LibC_space" width="100%" height="1px" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&lt;/div&gt; &lt;div class="cleartabstrip"&gt;&lt;/div&gt; &lt;div id="ctl00_ctl09_tabs_LocalNavBottom" class="LocalNavBottom"&gt;&lt;/div&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    &lt;/div&gt;&lt;/div&gt;&lt;div class="Clear"&gt;&lt;/div&gt;    &lt;div id="ctl00_ib1_Panel1" class="miniRatings"&gt; &lt;br /&gt;&lt;div id="ctl00_ib1_miniRatings_left" class="miniRatings_left"&gt;  &lt;br /&gt;    &lt;a id="ctl00_ib1_hlPrint" title="Print This Content" class="itPrint" onclick="javascript:SubmitRateAction('printerFriendlyPage');" href="http://msdn.microsoft.com/en-us/library/bhc3fa7f(printer).aspx"&gt;&lt;img id="ctl00_ib1_imgPrint" class="LibC_rtg_print" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&amp;nbsp;Printer Friendly Version&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;    &lt;a id="ctl00_ib1_hlFav" title="Add To Favorites" class="itFav" onclick="javascript:SubmitRateAction('addToFavorites');" href="javascript:OnSave();"&gt;&lt;img id="ctl00_ib1_imgFav" class="LibC_rtg_save" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&amp;nbsp;Add To Favorites&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;    &lt;a id="ctl00_ib1_hlSendCont" title="Send This Content" class="itSend" onclick="javascript:SubmitRateAction('sendThisPage');" href="mailto:?subject=Writing CLS-Compliant Code&amp;amp;body=This URL points to a page on MSDN that may interest you: http://msdn.microsoft.com/en-us/library/bhc3fa7f.aspx"&gt;&lt;img id="ctl00_ib1_imgSendCont" class="LibC_rtg_email" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&amp;nbsp;Send&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;    &lt;a id="ctl00_ib1_hlComCon" title="Click here to jump to the Community Content section on this page." class="itComCon" href="http://msdn.microsoft.com/en-us/library/Community-Signup.aspx?ru=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fbhc3fa7f(VS.90).aspx%3fwbi%3dnew"&gt;&lt;img id="ctl00_ib1_imgComCon" class="LibC_rtg_comCon" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&amp;nbsp;Add Content...&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;   &lt;br /&gt; &lt;/div&gt;&lt;div id="ctl00_ib1_miniRatings_right" class="miniRatings_right"&gt;  &lt;br /&gt;        &lt;div class="ratingFlyoutStatic" style="position:relative;" id="ctl00_ib1_Flyout"&gt;&lt;div id="ctl00_ib1_Flyout_rtgContainer" title="Turn scripting on  to submit a rating and send feedback." style="display: block; text-align:right;"&gt;    &lt;br /&gt;              &lt;table&gt;                &lt;tr&gt;                  &lt;td style="text-align:right;line-height:70%;"&gt;&lt;br /&gt;                    &lt;span id="ctl00_ib1_Flyout_rateTitleLabel" class="tbFont"&gt;Click to Rate and Give Feedback&lt;/span&gt;&lt;br /&gt;                  &lt;/td&gt;                  &lt;td id="ctl00_ib1_Flyout_tdRtg" style="width:85px" onclick="if($get('ctl00_ib1_Flyout_tbComments')!=null &amp;amp;&amp;amp; $get('ctl00_ib1_Flyout_tbComments').visible == 'true') $get('ctl00_ib1_Flyout_tbComments').focus();"&gt;&lt;br /&gt;                      &lt;div id="ctl00_ib1_Flyout_Rating1" title="Click a star and provide feedback" dir="ltr" style="height:16px;"&gt;     &lt;a href="#" id="ctl00_ib1_Flyout_Rating1_A" title="Click a star and provide feedback" style="text-decoration:none"&gt;&lt;span id="ctl00_ib1_Flyout_Rating1_Star_1" class="ratingStar filledRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span id="ctl00_ib1_Flyout_Rating1_Star_2" class="ratingStar filledRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span id="ctl00_ib1_Flyout_Rating1_Star_3" class="ratingStar filledRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span id="ctl00_ib1_Flyout_Rating1_Star_4" class="ratingStar emptyRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span id="ctl00_ib1_Flyout_Rating1_Star_5" class="ratingStar emptyRatingStar" style="float:left;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;    &lt;/div&gt;                  &lt;/td&gt;                    &lt;/tr&gt;              &lt;/table&gt;            &lt;br /&gt;   &lt;/div&gt;            &lt;div style="display: block; float: none; clear: both;"&gt;            &lt;/div&gt;          &lt;div id="ctl00_ib1_Flyout_Popup" class="ratingFlyoutPopup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;    &lt;span id="ctl00_ib1_Flyout_lbOptText" class="OptionalText"&gt;Give feedback on this content&lt;/span&gt;&lt;textarea name="ctl00$ib1$Flyout$tbComments" rows="2" cols="20" id="ctl00_ib1_Flyout_tbComments" class="Comment"&gt;&lt;/textarea&gt;&lt;input name="ctl00$ib1$Flyout$btnClose" type="button" id="ctl00_ib1_Flyout_btnClose" Class="Button" value="Close" OnClick="CloseFLY(&amp;quot;ctl00_ib1_Flyout&amp;quot;) " /&gt;&lt;input name="ctl00$ib1$Flyout$btnSend" type="button" id="ctl00_ib1_Flyout_btnSend" Class="Button" value="Send" OnClick="return IsPageRated(&amp;quot;ctl00_ib1_Flyout_Rating1&amp;quot;,&amp;quot;ctl00_ib1_Flyout_lbOptText&amp;quot;,'Please rate the page first.', &amp;quot;ctl00_ib1_Flyout&amp;quot;,this)" /&gt;&lt;/div&gt;&lt;div id="ctl00_ib1_Flyout_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;br /&gt;      &lt;br /&gt; &lt;/div&gt;    &lt;br /&gt;  &lt;div id="intercleardiv" style="display: block; clear: both; visibility: hidden;"&gt;&lt;/div&gt; &lt;br /&gt;&lt;/div&gt; &lt;br /&gt;  &lt;/div&gt;  &lt;div id="contents"&gt;   &lt;div id="ctl00_LibFrame" class="resizableArea"&gt; &lt;div id="ctl00_raLeft" class="leftSection" style="width:86px;"&gt;  &lt;br /&gt;        &lt;img id="ctl00_TocVector1_o" class="hidden" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&lt;br /&gt;&lt;img id="ctl00_TocVector1_c" class="hidden" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&lt;br /&gt;&lt;img id="ctl00_TocVector1_e" class="hidden" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&lt;br /&gt;&lt;div id="holder" onclick="TocClick(event)"&gt;&lt;div id="ctl00_TocVector1_root" class="rootToc"&gt;   &lt;ul class="toc" id="tocVectorTreeId"&gt;&lt;li name="ms310241(n)"&gt;&lt;img src="http://i.msdn.microsoft.com/Global/Images/clear.gif" class="LibC_c"/&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms123401.aspx" target="_top"&gt;MSDN Library&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;  &lt;/div&gt;&lt;/div&gt; &lt;br /&gt; &lt;br /&gt;      &lt;br /&gt; &lt;/div&gt;&lt;div id="ctl00_raSplitter" title="Click and drag to resize. Double click or press 't' to toggle visibility." class="splitter" style="left:86px;"&gt;  &lt;div class="LibC_lib_grippy" style="position:absolute;top:50%;"&gt;&lt;/div&gt; &lt;/div&gt;&lt;div id="ctl00_raRight" class="rightSection"&gt;  &lt;br /&gt;        &lt;div &gt;          &lt;div id="ctl00_eb1_Panel1" class="EyebrowMenuBar"&gt;   &lt;br /&gt;&lt;div class="stat" style="position:relative;" id="ctl00_eb1_ctl00"&gt;&lt;a title="MSDN" href="http://msdn.microsoft.com/en-us/ms348103.aspx"&gt;MSDN&lt;/a&gt;&lt;div id="ctl00_eb1_ctl00_Popup" class="popup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;     &lt;span name="http://msdn.microsoft.com/en-us/library/36cf08ac-18d1-4fe0-abc8-466852a0f9c7(n).aspx"&gt;Please Wait&lt;/span&gt;&lt;/div&gt;&lt;div id="ctl00_eb1_ctl00_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;   &lt;/div&gt;   &lt;div class="stat" style="position:relative;" id="ctl00_eb1_ctl01"&gt;&lt;a title="MSDN Library" href="http://msdn.microsoft.com/en-us/library/ms123401.aspx"&gt;MSDN Library&lt;/a&gt;&lt;div id="ctl00_eb1_ctl01_Popup" class="popup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;     &lt;span name="http://msdn.microsoft.com/en-us/library/ms310241(n).aspx"&gt;Please Wait&lt;/span&gt;&lt;/div&gt;&lt;div id="ctl00_eb1_ctl01_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;   &lt;/div&gt;   &lt;div class="stat" style="position:relative;" id="ctl00_eb1_ctl02"&gt;&lt;a title="Development Tools and Languages" href="http://msdn.microsoft.com/en-us/library/aa187916.aspx"&gt;Development Tools and Languages&lt;/a&gt;&lt;div id="ctl00_eb1_ctl02_Popup" class="popup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;     &lt;span name="http://msdn.microsoft.com/en-us/library/aa187916(n).aspx"&gt;Please Wait&lt;/span&gt;&lt;/div&gt;&lt;div id="ctl00_eb1_ctl02_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;   &lt;/div&gt;   &lt;div class="stat" style="position:relative;" id="ctl00_eb1_ctl03"&gt;&lt;a title="Visual Studio 2008" href="http://msdn.microsoft.com/en-us/library/aa187919.aspx"&gt;Visual Studio 2008&lt;/a&gt;&lt;div id="ctl00_eb1_ctl03_Popup" class="popup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;     &lt;span name="http://msdn.microsoft.com/en-us/library/aa187919(n).aspx"&gt;Please Wait&lt;/span&gt;&lt;/div&gt;&lt;div id="ctl00_eb1_ctl03_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;   &lt;/div&gt;   &lt;div class="stat" style="position:relative;" id="ctl00_eb1_ctl04"&gt;&lt;a title="Visual Studio" href="http://msdn.microsoft.com/en-us/library/52f3sw5c.aspx"&gt;Visual Studio&lt;/a&gt;&lt;div id="ctl00_eb1_ctl04_Popup" class="popup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;     &lt;span name="http://msdn.microsoft.com/en-us/library/bb400865(n).aspx"&gt;Please Wait&lt;/span&gt;&lt;/div&gt;&lt;div id="ctl00_eb1_ctl04_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;   &lt;/div&gt;   &lt;div class="stat" style="position:relative;" id="ctl00_eb1_ctl05"&gt;&lt;a title=".NET Framework Programming in Visual Studio" href="http://msdn.microsoft.com/en-us/library/k1s94fta.aspx"&gt;.NET Framework Programming in Visua...&lt;/a&gt;&lt;div id="ctl00_eb1_ctl05_Popup" class="popup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;     &lt;span name="http://msdn.microsoft.com/en-us/library/ms299694(n).aspx"&gt;Please Wait&lt;/span&gt;&lt;/div&gt;&lt;div id="ctl00_eb1_ctl05_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;   &lt;/div&gt;   &lt;div class="stat" style="position:relative;" id="ctl00_eb1_ctl06"&gt;&lt;a title="Overview of the .NET Framework" href="http://msdn.microsoft.com/en-us/library/a4t23ktk.aspx"&gt;Overview of the .NET Framework&lt;/a&gt;&lt;div id="ctl00_eb1_ctl06_Popup" class="popup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;     &lt;span name="http://msdn.microsoft.com/en-us/library/ms298723(n).aspx"&gt;Please Wait&lt;/span&gt;&lt;/div&gt;&lt;div id="ctl00_eb1_ctl06_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;   &lt;/div&gt;   &lt;div class="stat" style="position:relative;" id="ctl00_eb1_ctl07"&gt;&lt;a title="Cross-Language Interoperability" href="http://msdn.microsoft.com/en-us/library/730f1wy3.aspx"&gt;Cross-Language Interoperability&lt;/a&gt;&lt;div id="ctl00_eb1_ctl07_Popup" class="popup" style="position: absolute;visibility:hidden;left:-1000px;"&gt;     &lt;span name="http://msdn.microsoft.com/en-us/library/ms298739(n).aspx"&gt;Please Wait&lt;/span&gt;&lt;/div&gt;&lt;div id="ctl00_eb1_ctl07_Anim" class="TFlyPopupAnimate"&gt;&lt;/div&gt;   &lt;/div&gt;   &lt;div class="nochildstat"&gt;&lt;strong&gt;&amp;nbsp;Writing CLS-Compliant Code&lt;/strong&gt;&lt;/div&gt;&lt;span style="float:none;clear:both;display:block;"&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt; &lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt; &lt;br /&gt;        &lt;div class="RightPanel"&gt;          &lt;div class="ContentBar"&gt;            &lt;br /&gt;&lt;div id="ECDiv" class="ECPanel"&gt;&lt;img id="ECImg" class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" alt="Collapse All/Expand All" align="middle" style="border-width:0px;" /&gt;&lt;br /&gt;&lt;span id="ECCollapse" class="ECLink" &gt;Collapse All&lt;/span&gt;&lt;br /&gt;&lt;span id="ECExpand" class="ECLink" style="display:none"&gt;Expand All&lt;/span&gt;&lt;br /&gt;&lt;/div&gt; &lt;br /&gt; &lt;br /&gt;            &lt;br /&gt;&lt;script type="text/Javascript"&gt; var visualbasic = new Array(2);visualbasic[0] = "ctl00_MTCS_main_ctl19_ctl00_ctl01_VisualBasic";visualbasic[1] = "ctl00_MTCS_main_ctl19_ctl00_ctl05_VisualBasic";var csharp = new Array(2);csharp[0] = "ctl00_MTCS_main_ctl19_ctl00_ctl02_CSharp";csharp[1] = "ctl00_MTCS_main_ctl19_ctl00_ctl06_CSharp";&lt;/script&gt;&lt;br /&gt; &lt;br /&gt;&lt;style type="text/css"&gt; .vb, .cs, .cpp, .nu, .fs{ display:none;}&lt;/style&gt;&lt;br /&gt;&lt;style id="LanguageSpecificTextStyle" type="text/css"&gt; .nu{   display:inline;}&lt;/style&gt;&lt;div id="ctl00_DropDownFilter_DropDownFilterMain" class="DropDownFilterStyle"&gt;&lt;img id="ctl00_DropDownFilter_MTPS_DD_ImageArrow" title="Language Filter" class="MTPS_DropDownImage LibC_arrow-off" onclick="DDFilterOn(event);" onmouseover="ChangeDropDownImage(true);ResetLanguagesMenuTimer(event);" onmouseout="ChangeDropDownImage(false);RequestHideLanguagesMenu();" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" alt="Language Filter" style="border-width:0px;" /&gt;&lt;a id="ctl00_DropDownFilter_Mtps_DropDownFilterText" title="Language Filter" class="DropDownFilterOff" onclick="DDFilterOn(event);" onmouseover="ChangeDropDownImage(true);" onmouseout="ChangeDropDownImage(false);" href="/en-us/library/bhc3fa7f.aspx#Mtps_DropDownFilterText"&gt;Language Filter&lt;/a&gt;&lt;div id="ctl00_DropDownFilter_Mtps_DropDownPopUp" style="display:none" class="MTPS_PopupDivPanel" onmouseover="ResetLanguagesMenuTimer(event);" onmouseout="RequestHideLanguagesMenu();"&gt;&lt;div class="DivCbxLabelLanguage"&gt;   &lt;input name="ctl00$DropDownFilter$DropDownLngFilterCtrl" type="checkbox" id="ctl00_DropDownFilter_DropDownLngFilterCtrl" checked="checked" value="Visual Basic" arrayValue="visualbasic" onclick="SetLangFilter('visualbasic',false);" /&gt;&lt;span id="ctl00_DropDownFilter_ctl00_DropDownFilter_DropDownLngFilterCtrl_0" title="Visual Basic"&gt;Visual Basic&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;&lt;div class="DivCbxLabelLanguage"&gt;   &lt;input name="ctl00$DropDownFilter$DropDownLngFilterCtrl" type="checkbox" id="ctl00_DropDownFilter_DropDownLngFilterCtrl" checked="checked" value="C#" arrayValue="csharp" onclick="SetLangFilter('csharp',false);" /&gt;&lt;span id="ctl00_DropDownFilter_ctl00_DropDownFilter_DropDownLngFilterCtrl_1" title="C#"&gt;C#&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;&lt;div class="DivCbxLabelLanguage"&gt;   &lt;input name="ctl00$DropDownFilter$DropDownLngFilterCtrl" type="checkbox" id="ctl00_DropDownFilter_DropDownLngFilterCtrl" checked="checked" value="C++" arrayValue="managedcplusplus" onclick="SetLangFilter(null,false);" /&gt;&lt;span id="ctl00_DropDownFilter_ctl00_DropDownFilter_DropDownLngFilterCtrl_2" title="C++"&gt;C++&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;&lt;div class="DivCbxLabelLanguage"&gt;   &lt;input name="ctl00$DropDownFilter$DropDownLngFilterCtrl" type="checkbox" id="ctl00_DropDownFilter_DropDownLngFilterCtrl" checked="checked" value="J#" arrayValue="jsharp" onclick="SetLangFilter(null,false);" /&gt;&lt;span id="ctl00_DropDownFilter_ctl00_DropDownFilter_DropDownLngFilterCtrl_3" title="J#"&gt;J#&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;&lt;div class="DivCbxLabelLanguage"&gt;   &lt;input name="ctl00$DropDownFilter$DropDownLngFilterCtrl" type="checkbox" id="ctl00_DropDownFilter_DropDownLngFilterCtrl" checked="checked" value="JScript" arrayValue="jscript" onclick="SetLangFilter(null,false);" /&gt;&lt;span id="ctl00_DropDownFilter_ctl00_DropDownFilter_DropDownLngFilterCtrl_4" title="JScript"&gt;JScript&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;&lt;div class="DivCbxLabelLanguage"&gt;   &lt;input name="ctl00$DropDownFilter$DropDownLngFilterCtrl" type="checkbox" id="ctl00_DropDownFilter_DropDownLngFilterCtrl" checked="checked" value="XAML" arrayValue="xaml" onclick="SetLangFilter(null,false);" /&gt;&lt;span id="ctl00_DropDownFilter_ctl00_DropDownFilter_DropDownLngFilterCtrl_5" title="XAML"&gt;XAML&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;&lt;div class="DivCbxLabelLanguage"&gt;   &lt;input name="ctl00$DropDownFilter$DropDownLngFilterCtrl" type="checkbox" id="ctl00_DropDownFilter_DropDownLngFilterCtrl" checked="checked" value="F#" arrayValue="fsharp" onclick="SetLangFilter(null,false);" /&gt;&lt;span id="ctl00_DropDownFilter_ctl00_DropDownFilter_DropDownLngFilterCtrl_6" title="F#"&gt;F#&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;&lt;/div&gt;&lt;script type="text/Javascript"&gt; var strConstLangFilterAll ="All";var strConstLangFilterMulti ="Multiple";var strConstLangFilterNone ="None";var strConstLangFilterText ="Language Filter";var oMTPS_DD_ImgArrow = document.getElementById("ctl00_DropDownFilter_MTPS_DD_ImageArrow");var oMTPS_DD_PanelLink = document.getElementById("ctl00_DropDownFilter_Mtps_DropDownFilterText");var oMTPS_DD_Div = document.getElementById("ctl00_DropDownFilter_DropDownFilterMain");var oMTPS_DD_PopUpDiv = document.getElementById("ctl00_DropDownFilter_Mtps_DropDownPopUp");&lt;/script&gt;&lt;br /&gt;&lt;/div&gt;              &lt;br /&gt;            &lt;br /&gt;            &lt;br /&gt;          &lt;/div&gt;           &lt;div class="ContentArea"&gt;      &lt;br /&gt;          &lt;br /&gt;          &lt;span id="ctl00_altSelector"&gt;&lt;div class="AlterPart"&gt;   &lt;div&gt;    This page is specific to&lt;br /&gt;  &lt;br /&gt;   &lt;/div&gt;&lt;span&gt;Microsoft Visual Studio 2008/.NET Framework 3.5&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;div&gt;    Other versions are also available for the following:&lt;br /&gt;  &lt;br /&gt;   &lt;/div&gt;&lt;div id="ctl00_ctl04"&gt;    &lt;ul&gt;&lt;li&gt;&lt;a id="ctl00_ctl05" href="http://msdn.microsoft.com/en-us/library/bhc3fa7f(VS.71).aspx" onclick="javascript:Track('ctl00_ctl04|ctl00_ctl05',this);"&gt;Microsoft Visual Studio 2003/.NET Framework 1.1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a id="ctl00_ctl06" href="http://msdn.microsoft.com/en-us/library/bhc3fa7f(VS.80).aspx" onclick="javascript:Track('ctl00_ctl04|ctl00_ctl06',this);"&gt;Microsoft Visual Studio 2005/.NET Framework 2.0&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a id="ctl00_ctl07" href="http://msdn.microsoft.com/en-us/library/bhc3fa7f(VS.85).aspx" onclick="javascript:Track('ctl00_ctl04|ctl00_ctl07',this);"&gt;.NET Framework 3.0&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a id="ctl00_ctl08" href="http://msdn.microsoft.com/en-us/library/bhc3fa7f(VS.100).aspx" onclick="javascript:Track('ctl00_ctl04|ctl00_ctl08',this);"&gt;Microsoft Visual Studio 2010/.NET Framework 4&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;   &lt;/div&gt;  &lt;/div&gt;&lt;/span&gt;&lt;br /&gt;          &lt;br /&gt;          &lt;br /&gt;          &lt;br /&gt;        &lt;br /&gt;          &lt;!--starting processing--&gt;&lt;div class="topic" &gt;&lt;div class="majorTitle"&gt;.NET Framework Developer's Guide&lt;!----&gt;&lt;/div&gt;&lt;div class="title"&gt;Writing CLS-Compliant Code&lt;!----&gt;&lt;/div&gt;&lt;!--Content type: Devdiv1. Transform: orcas2mtps.xslt.--&gt;&lt;div id="mainSection"&gt;      &lt;div id="mainBody"&gt;        &lt;br /&gt;        &lt;br /&gt;        &lt;p&gt;&lt;!----&gt;&lt;/p&gt;&lt;div class="introduction"&gt;&lt;p&gt;Common Language Specification (CLS) compliance generally refers to the claim that CLS rules and restrictions are being followed. However, the concept has a more specific meaning depending on whether you are describing CLS-compliant code or CLS-compliant development tools, such as a compiler. CLS-compliant tools can help you write CLS-compliant code.&lt;/p&gt;&lt;/div&gt;&lt;span&gt;&lt;br /&gt;&lt;div  class="MTPS_CollapsibleRegion"&gt;&lt;div  class="CollapseRegionLink"&gt;&lt;!-- ApplyClick with current id --&gt;&lt;br /&gt;&lt;img  class='LibC_o' src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style='border-width:0px;vertical-align:middle;' /&gt;&lt;br /&gt;&amp;nbsp;CLS-Compliant Code&lt;br /&gt;&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style='display:block;' &gt;&lt;a id="sectionToggle0"&gt;&lt;!----&gt;&lt;/a&gt;&lt;p&gt;If you want your code to be CLS-compliant, you must expose functionality in a way that is CLS-compliant in the following places:  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Definitions of your public classes.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Definitions of the public members of public classes, and of members accessible to derived classes (&lt;strong&gt;family&lt;/strong&gt; access).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Parameters and return types of public methods of public classes, and of methods accessible to derived classes.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The features you use in the definitions of your private classes, in the definitions of private methods on public classes, and in local variables do not have to follow the CLS rules. You can also use any language features you want in the code that implements your class and still have a CLS-compliant component.&lt;/p&gt;&lt;div class="alert"&gt;&lt;table&gt;&lt;tr&gt;&lt;th&gt;&lt;!--src=[../icons/alert_note.gif]--&gt;&lt;img alt="Note" src="http://i.msdn.microsoft.com/bhc3fa7f.alert_note(en-us,VS.90).gif" /&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;Jagged arrays — that is, arrays of arrays — are CLS-compliant. In the .NET Framework version 1.0, the C# compiler mistakenly reports that they are not.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;You can mark assemblies, modules, types, and members as either CLS-compliant or not CLS compliant using the &lt;span&gt;&lt;a id="ctl00_MTCS_main_ctl18_ctl00_ctl01" href="http://msdn.microsoft.com/en-us/library/system.clscompliantattribute.aspx" onclick="javascript:Track('ctl00_MTCS_main_ctl18_ctl00_contenthere|ctl00_MTCS_main_ctl18_ctl00_ctl01',this);"&gt;CLSCompliantAttribute&lt;/a&gt;&lt;/span&gt;. All assemblies that are intended to be CLS-compliant should be marked as such. An assembly that is not marked as CLS-compliant is considered to be not CLS compliant. If no CLS attribute is applied to a type, that type is assumed to have the same CLS compliance as the assembly in which the type is defined. Similarly, if no CLS attribute is applied to a member, the member is considered to have the same CLS compliance as the type that defines it. You cannot mark a program element as CLS-compliant if its enclosing element is not marked as CLS-compliant. The example at the end of this topic illustrates the use of the &lt;span&gt;&lt;a id="ctl00_MTCS_main_ctl18_ctl00_ctl02" href="http://msdn.microsoft.com/en-us/library/system.clscompliantattribute.aspx" onclick="javascript:Track('ctl00_MTCS_main_ctl18_ctl00_contenthere|ctl00_MTCS_main_ctl18_ctl00_ctl02',this);"&gt;CLSCompliantAttribute&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;Assemblies, modules, and types can be CLS-compliant even if some parts of the assembly, module, or type are not CLS-compliant, as long as two conditions are met:  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;If the element is marked as CLS-compliant, the parts that are not CLS-compliant must be marked using the &lt;span&gt;&lt;a id="ctl00_MTCS_main_ctl18_ctl00_ctl03" href="http://msdn.microsoft.com/en-us/library/system.clscompliantattribute.aspx" onclick="javascript:Track('ctl00_MTCS_main_ctl18_ctl00_contenthere|ctl00_MTCS_main_ctl18_ctl00_ctl03',this);"&gt;CLSCompliantAttribute&lt;/a&gt;&lt;/span&gt; with its argument set to &lt;span&gt;&lt;span class="input"&gt;false&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;A comparable CLS-compliant alternative member must be supplied for each member that is not CLS-compliant.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If you design a CLS–compliant class library, your library will have a guarantee of interoperability with a wide range of programming languages; therefore, your library is likely to have a wider customer base than a version that is not CLS-compliant.&lt;/p&gt;&lt;p&gt;The .NET Framework provides a CLS-compliant class library. For more information about this class library, see &lt;span&gt;&lt;a id="ctl00_MTCS_main_ctl18_ctl00_ctl04" href="http://msdn.microsoft.com/en-us/library/ms229335.aspx" onclick="javascript:Track('ctl00_MTCS_main_ctl18_ctl00_contenthere|ctl00_MTCS_main_ctl18_ctl00_ctl04',this);"&gt;.NET Framework Class Library&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;div  class="MTPS_CollapsibleRegion"&gt;&lt;div  class="CollapseRegionLink"&gt;&lt;!-- ApplyClick with current id --&gt;&lt;br /&gt;&lt;img  class='LibC_o' src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style='border-width:0px;vertical-align:middle;' /&gt;&lt;br /&gt;&amp;nbsp;CLS-Compliant Tools&lt;br /&gt;&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style='display:block;' &gt;&lt;a id="sectionToggle1"&gt;&lt;!----&gt;&lt;/a&gt;&lt;p&gt;Languages that target the runtime have agreed to support CLS features and follow the CLS rules directed to compilers. These language compilers simplify CLS compliance by making the CLS data types and features available for creating components. The levels of CLS compliance among compilers and other tools are described as follows:  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;CLS-compliant consumer tools. &lt;/p&gt;&lt;p&gt;Consumer tools are languages that enable developers to access all the features supplied by CLS-compliant libraries. Developers using these languages might not be able to extend CLS-compliant libraries by creating new types, but they can use any type defined by a compliant library. This level of compliance can be useful when you want to access a .NET Framework class library, but do not need to author new objects for consumption by others, such as when you are using Web Forms on an ASP.NET page or creating a Windows Forms user interface. &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;CLS-compliant extender tools. &lt;/p&gt;&lt;p&gt;Extender tools are languages that allow developers to both use and extend types defined in CLS-compliant libraries. Developers can use existing types as well as define new types. Extender tools must follow all the rules that consumer tools must follow, as well as some additional rules, which are described in the specification for the Common Language Infrastructure, Partition I - Architecture, available from the &lt;a id="ctl00_MTCS_main_ctl19_ctl00_ctl00" href="http://go.microsoft.com/fwlink/?LinkId=99212" onclick="javascript:Track('ctl00_MTCS_main_ctl19_ctl00_contenthere|ctl00_MTCS_main_ctl19_ctl00_ctl00',this);"&gt;Microsoft Developer Network (MSDN)&lt;/a&gt; Web site. &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;When you design your own CLS-compliant components, it is helpful to use a CLS-compliant tool. Writing CLS-compliant components without this support is more difficult because otherwise you might not have access to all the CLS features you want to use.&lt;/p&gt;&lt;p&gt;Some CLS-compliant language compilers, such as the C# or Visual Basic compilers, enable you to specify that you intend your code to be CLS-compliant. These compilers can check for CLS compliance and let you know when your code uses functionality that is not supported by the CLS. The C# and Visual Basic compilers allow you to mark a program element as CLS-compliant, which will cause the compiler to generate a compile-time error if the code is not CLS-compliant. For example, the following code generates a compiler warning.&lt;/p&gt;&lt;div id="snippetGroup"&gt;&lt;span id="ctl00_MTCS_main_ctl19_ctl00_ctl01"&gt;&lt;br /&gt;&lt;div class='libCScode'id="ctl00_MTCS_main_ctl19_ctl00_ctl01_VisualBasic"&gt;    &lt;br /&gt;    &lt;div class="CodeSnippetTitleBar"&gt;        &lt;div class="CodeDisplayLanguage"&gt;            Visual Basic&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;        &lt;div class="CopyCodeButton"&gt;            &lt;a class="copyCode"             title="Copy Code"              href="javascript:CopyCode('ctl00_MTCS_main_ctl19_ctl00_ctl01_code');"&gt;&lt;br /&gt;                &lt;div style="border: 0px; height: 9px; width: auto" align="center" class="LibC_copy_off"&gt;&lt;/div&gt;                Copy Code&lt;br /&gt;             &lt;/a&gt;&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;    &lt;/div&gt;    &lt;div dir="ltr" style="background-color: #ddd"&gt;    &lt;pre class="libCScode" id="ctl00_MTCS_main_ctl19_ctl00_ctl01_code" space="preserve"&gt;&amp;lt;Assembly: CLSCompliant(&lt;span style="color:blue"&gt;True&lt;/span&gt;)&amp;gt;&lt;br /&gt; &lt;br /&gt;&amp;lt;CLSCompliant(&lt;span style="color:blue"&gt;True&lt;/span&gt;)&amp;gt; &lt;span style="color:blue"&gt;Public&lt;/span&gt; &lt;span style="color:blue"&gt;Class&lt;/span&gt; MyCompliantClass&lt;br /&gt;   &lt;span style="color:blue"&gt;Public&lt;/span&gt; &lt;span style="color:blue"&gt;Sub&lt;/span&gt; ChangeValue(value &lt;span style="color:blue"&gt;As&lt;/span&gt; UInt32)&lt;br /&gt;   &lt;span style="color:blue"&gt;End&lt;/span&gt; &lt;span style="color:blue"&gt;Sub&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;   &lt;span style="color:blue"&gt;Public&lt;/span&gt; &lt;span style="color:blue"&gt;Shared&lt;/span&gt; &lt;span style="color:blue"&gt;Sub&lt;/span&gt; Main()&lt;br /&gt;      &lt;span style="color:blue"&gt;Dim&lt;/span&gt; i &lt;span style="color:blue"&gt;As&lt;/span&gt; &lt;span style="color:blue"&gt;Integer&lt;/span&gt; = 2&lt;br /&gt;      Console.WriteLine(i)&lt;br /&gt;   &lt;span style="color:blue"&gt;End&lt;/span&gt; &lt;span style="color:blue"&gt;Sub&lt;/span&gt;   &lt;br /&gt;&lt;span style="color:blue"&gt;End&lt;/span&gt; &lt;span style="color:blue"&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;    &lt;/div&gt;&lt;/div&gt; &lt;br /&gt;&lt;/span&gt;&lt;span id="ctl00_MTCS_main_ctl19_ctl00_ctl02"&gt;&lt;br /&gt;&lt;div class='libCScode'id="ctl00_MTCS_main_ctl19_ctl00_ctl02_CSharp"&gt;    &lt;br /&gt;    &lt;div class="CodeSnippetTitleBar"&gt;        &lt;div class="CodeDisplayLanguage"&gt;            C#&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;        &lt;div class="CopyCodeButton"&gt;            &lt;a class="copyCode"             title="Copy Code"              href="javascript:CopyCode('ctl00_MTCS_main_ctl19_ctl00_ctl02_code');"&gt;&lt;br /&gt;                &lt;div style="border: 0px; height: 9px; width: auto" align="center" class="LibC_copy_off"&gt;&lt;/div&gt;                Copy Code&lt;br /&gt;             &lt;/a&gt;&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;    &lt;/div&gt;    &lt;div dir="ltr" style="background-color: #ddd"&gt;    &lt;pre class="libCScode" id="ctl00_MTCS_main_ctl19_ctl00_ctl02_code" space="preserve"&gt;&lt;span style="color:blue"&gt;using&lt;/span&gt; System;&lt;br /&gt; &lt;br /&gt;&lt;span style="color:green"&gt;// Assembly marked as compliant.&lt;/span&gt;&lt;br /&gt;[assembly: CLSCompliant(&lt;span style="color:blue"&gt;true&lt;/span&gt;)]&lt;br /&gt; &lt;br /&gt;&lt;span style="color:green"&gt;// Class marked as compliant.&lt;/span&gt;&lt;br /&gt;[CLSCompliant(&lt;span style="color:blue"&gt;true&lt;/span&gt;)]&lt;br /&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;class&lt;/span&gt; MyCompliantClass {&lt;br /&gt;   &lt;span style="color:green"&gt;// ChangeValue exposes UInt32, which is not in CLS.&lt;/span&gt;&lt;br /&gt;   &lt;span style="color:green"&gt;// A compile-time warning results.&lt;/span&gt;&lt;br /&gt;   &lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; ChangeValue(UInt32 value){ }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;static&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; Main( ) {&lt;br /&gt;   &lt;span style="color:blue"&gt;int&lt;/span&gt; i = 2;&lt;br /&gt;   Console.WriteLine(i);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;    &lt;/div&gt;&lt;/div&gt; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;This code generates the following C# warning:&lt;/p&gt;&lt;span id="ctl00_MTCS_main_ctl19_ctl00_ctl03"&gt;&lt;br /&gt;&lt;div class='libCScode'id="ctl00_MTCS_main_ctl19_ctl00_ctl03_"&gt;    &lt;br /&gt;    &lt;div class="CodeSnippetTitleBar"&gt;        &lt;div class="CodeDisplayLanguage"&gt;            &lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;        &lt;div class="CopyCodeButton"&gt;            &lt;a class="copyCode"             title="Copy Code"              href="javascript:CopyCode('ctl00_MTCS_main_ctl19_ctl00_ctl03_code');"&gt;&lt;br /&gt;                &lt;div style="border: 0px; height: 9px; width: auto" align="center" class="LibC_copy_off"&gt;&lt;/div&gt;                Copy Code&lt;br /&gt;             &lt;/a&gt;&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;    &lt;/div&gt;    &lt;div dir="ltr" style="background-color: #ddd"&gt;    &lt;pre class="libCScode" id="ctl00_MTCS_main_ctl19_ctl00_ctl03_code" space="preserve"&gt;warning CS3001: Argument type 'uint' is not CLS-compliant&lt;br /&gt;&lt;/pre&gt;    &lt;/div&gt;&lt;/div&gt; &lt;br /&gt;&lt;/span&gt;&lt;p&gt;or the following Visual Basic warning:&lt;/p&gt;&lt;span id="ctl00_MTCS_main_ctl19_ctl00_ctl04"&gt;&lt;br /&gt;&lt;div class='libCScode'id="ctl00_MTCS_main_ctl19_ctl00_ctl04_"&gt;    &lt;br /&gt;    &lt;div class="CodeSnippetTitleBar"&gt;        &lt;div class="CodeDisplayLanguage"&gt;            &lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;        &lt;div class="CopyCodeButton"&gt;            &lt;a class="copyCode"             title="Copy Code"              href="javascript:CopyCode('ctl00_MTCS_main_ctl19_ctl00_ctl04_code');"&gt;&lt;br /&gt;                &lt;div style="border: 0px; height: 9px; width: auto" align="center" class="LibC_copy_off"&gt;&lt;/div&gt;                Copy Code&lt;br /&gt;             &lt;/a&gt;&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;    &lt;/div&gt;    &lt;div dir="ltr" style="background-color: #ddd"&gt;    &lt;pre class="libCScode" id="ctl00_MTCS_main_ctl19_ctl00_ctl04_code" space="preserve"&gt;warning BC40028: Type of parameter 'value' is not CLS-compliant.&lt;br /&gt;&lt;/pre&gt;    &lt;/div&gt;&lt;/div&gt; &lt;br /&gt;&lt;/span&gt;&lt;p&gt;To remove the warning, you can indicate that &lt;span class="code"&gt;ChangeValue&lt;/span&gt; is not compliant, as shown in the following example.&lt;/p&gt;&lt;div id="snippetGroup1"&gt;&lt;span id="ctl00_MTCS_main_ctl19_ctl00_ctl05"&gt;&lt;br /&gt;&lt;div class='libCScode'id="ctl00_MTCS_main_ctl19_ctl00_ctl05_VisualBasic"&gt;    &lt;br /&gt;    &lt;div class="CodeSnippetTitleBar"&gt;        &lt;div class="CodeDisplayLanguage"&gt;            Visual Basic&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;        &lt;div class="CopyCodeButton"&gt;            &lt;a class="copyCode"             title="Copy Code"              href="javascript:CopyCode('ctl00_MTCS_main_ctl19_ctl00_ctl05_code');"&gt;&lt;br /&gt;                &lt;div style="border: 0px; height: 9px; width: auto" align="center" class="LibC_copy_off"&gt;&lt;/div&gt;                Copy Code&lt;br /&gt;             &lt;/a&gt;&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;    &lt;/div&gt;    &lt;div dir="ltr" style="background-color: #ddd"&gt;    &lt;pre class="libCScode" id="ctl00_MTCS_main_ctl19_ctl00_ctl05_code" space="preserve"&gt;&lt;span style="color:green"&gt;' Assembly marked as compliant.&lt;/span&gt;&lt;br /&gt;&amp;lt;Assembly: CLSCompliant(&lt;span style="color:blue"&gt;True&lt;/span&gt;)&amp;gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="color:green"&gt;' Class marked as compliant.&lt;/span&gt;&lt;br /&gt;&amp;lt;CLSCompliant(&lt;span style="color:blue"&gt;True&lt;/span&gt;)&amp;gt; &lt;span style="color:blue"&gt;Public&lt;/span&gt; &lt;span style="color:blue"&gt;Class&lt;/span&gt; MyCompliantClass&lt;br /&gt;   &lt;span style="color:green"&gt;' Method marked as not compliant.&lt;/span&gt;&lt;br /&gt;   &amp;lt;CLSCompliant(&lt;span style="color:blue"&gt;False&lt;/span&gt;)&amp;gt; &lt;span style="color:blue"&gt;Public&lt;/span&gt; &lt;span style="color:blue"&gt;Sub&lt;/span&gt; ChangeValue(value &lt;span style="color:blue"&gt;As&lt;/span&gt; UInt32)&lt;br /&gt;   &lt;span style="color:blue"&gt;End&lt;/span&gt; &lt;span style="color:blue"&gt;Sub&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;   &lt;span style="color:blue"&gt;Public&lt;/span&gt; &lt;span style="color:blue"&gt;Shared&lt;/span&gt; &lt;span style="color:blue"&gt;Sub&lt;/span&gt; Main()&lt;br /&gt;      &lt;span style="color:blue"&gt;Dim&lt;/span&gt; i &lt;span style="color:blue"&gt;As&lt;/span&gt; &lt;span style="color:blue"&gt;Integer&lt;/span&gt; = 2&lt;br /&gt;      Console.WriteLine(i)&lt;br /&gt;   &lt;span style="color:blue"&gt;End&lt;/span&gt; &lt;span style="color:blue"&gt;Sub&lt;/span&gt;   &lt;br /&gt;&lt;span style="color:blue"&gt;End&lt;/span&gt; &lt;span style="color:blue"&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;    &lt;/div&gt;&lt;/div&gt; &lt;br /&gt;&lt;/span&gt;&lt;span id="ctl00_MTCS_main_ctl19_ctl00_ctl06"&gt;&lt;br /&gt;&lt;div class='libCScode'id="ctl00_MTCS_main_ctl19_ctl00_ctl06_CSharp"&gt;    &lt;br /&gt;    &lt;div class="CodeSnippetTitleBar"&gt;        &lt;div class="CodeDisplayLanguage"&gt;            C#&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;        &lt;div class="CopyCodeButton"&gt;            &lt;a class="copyCode"             title="Copy Code"              href="javascript:CopyCode('ctl00_MTCS_main_ctl19_ctl00_ctl06_code');"&gt;&lt;br /&gt;                &lt;div style="border: 0px; height: 9px; width: auto" align="center" class="LibC_copy_off"&gt;&lt;/div&gt;                Copy Code&lt;br /&gt;             &lt;/a&gt;&lt;br /&gt;        &lt;/div&gt;        &lt;br /&gt;    &lt;/div&gt;    &lt;div dir="ltr" style="background-color: #ddd"&gt;    &lt;pre class="libCScode" id="ctl00_MTCS_main_ctl19_ctl00_ctl06_code" space="preserve"&gt;&lt;span style="color:blue"&gt;using&lt;/span&gt; System;&lt;br /&gt; &lt;br /&gt;&lt;span style="color:green"&gt;// Assembly marked as compliant.&lt;/span&gt;&lt;br /&gt;[assembly: CLSCompliantAttribute(&lt;span style="color:blue"&gt;true&lt;/span&gt;)]&lt;br /&gt; &lt;br /&gt;&lt;span style="color:green"&gt;// Class marked as compliant.&lt;/span&gt;&lt;br /&gt;[CLSCompliantAttribute(&lt;span style="color:blue"&gt;true&lt;/span&gt;)]&lt;br /&gt;&lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;class&lt;/span&gt; MyCompliantClass {&lt;br /&gt;   &lt;span style="color:green"&gt;// Method marked as not compliant.&lt;/span&gt;&lt;br /&gt;   [CLSCompliantAttribute(&lt;span style="color:blue"&gt;false&lt;/span&gt;)]&lt;br /&gt;   &lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; ChangeValue(UInt32 value){ }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color:blue"&gt;public&lt;/span&gt; &lt;span style="color:blue"&gt;static&lt;/span&gt; &lt;span style="color:blue"&gt;void&lt;/span&gt; Main( ) {&lt;br /&gt;   &lt;span style="color:blue"&gt;int&lt;/span&gt; i = 2;&lt;br /&gt;   Console.WriteLine(i);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;    &lt;/div&gt;&lt;/div&gt; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;This code produces no compiler warnings. The output is &lt;span class="code"&gt;2&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;For more information about how to specify the CLS-compliance of your code, see the documentation for the language compiler you are using.&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;div  class="MTPS_CollapsibleRegion"&gt;&lt;div  class="CollapseRegionLink"&gt;&lt;!-- ApplyClick with current id --&gt;&lt;br /&gt;&lt;img  class='LibC_o' src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style='border-width:0px;vertical-align:middle;' /&gt;&lt;br /&gt;&amp;nbsp;See Also&lt;br /&gt;&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style='display:block;' &gt;&lt;a id="seeAlsoToggle"&gt;&lt;!----&gt;&lt;/a&gt;&lt;h4 class="subHeading"&gt;Concepts&lt;/h4&gt;&lt;div class="seeAlsoStyle"&gt;&lt;span&gt;&lt;a id="ctl00_MTCS_main_ctl20_ctl00_ctl00" href="http://msdn.microsoft.com/en-us/library/a2c7tshk.aspx" onclick="javascript:Track('ctl00_MTCS_main_ctl20_ctl00_contenthere|ctl00_MTCS_main_ctl20_ctl00_ctl00',this);"&gt;Language Interoperability Overview&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;h4 class="subHeading"&gt;Other Resources&lt;/h4&gt;&lt;div class="seeAlsoStyle"&gt;&lt;span&gt;&lt;a id="ctl00_MTCS_main_ctl20_ctl00_ctl01" href="http://msdn.microsoft.com/en-us/library/730f1wy3.aspx" onclick="javascript:Track('ctl00_MTCS_main_ctl20_ctl00_contenthere|ctl00_MTCS_main_ctl20_ctl00_ctl01',this);"&gt;Cross-Language Interoperability&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;      &lt;br /&gt;    &lt;/div&gt;&lt;/div&gt;        &lt;br /&gt;          &lt;br /&gt;        &lt;/div&gt;      &lt;/div&gt; &lt;br /&gt;      &lt;br /&gt; &lt;br /&gt;&lt;span id="CommunityContent"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div id="ctl00_WikiContent_cc" class="CCS_Container"&gt;   &lt;br /&gt; &lt;br /&gt;  &lt;div class="CCS_TopicTagEditor"&gt;   &lt;div id="ctl00_WikiContent_TopicTagEditor_panel" class="CCT_Panel"&gt;  &lt;div id="tagsPanel" class="CCT_TagsPanel"&gt;    &lt;span id="ctl00_WikiContent_TopicTagEditor_title" class="CCT_Title"&gt;Tags&lt;/span&gt;&lt;br /&gt;    &lt;a href="/platform/Controls/CCTagEditor/resources/taghelp.htm" id="ctl00_WikiContent_TopicTagEditor_helpLink" class="CCT_HelpLink" onclick="CCS_ShowHelp(&amp;quot;/platform/Controls/CCTagEditor/resources/taghelp.htm&amp;quot;,800,600);return false;"&gt;&lt;br /&gt;      &lt;img src="http://i.msdn.microsoft.com/Global/Images/clear.gif" id="ctl00_WikiContent_TopicTagEditor_helpImage" class="CCT_HelpImage LibC_help" alt="What's this?" title="What's this?" /&gt;&lt;/a&gt;:&lt;br /&gt;    &lt;span id="ctl00_WikiContent_TopicTagEditor_tags" class="CCT_Text"&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span id="ctl00_WikiContent_TopicTagEditor_view" class="CCT_View"&gt;&lt;br /&gt;      &lt;a href="../../Platform/Controls/CCTagEditor/#" id="ctl00_WikiContent_TopicTagEditor_addTagLink" class="CCT_LinkButton" onclick="return CCT_AddATag(&amp;quot;http://msdn.microsoft.com/en-us/library/Community-Signup.aspx?ru=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fbhc3fa7f(VS.90).aspx&amp;quot;,-1);" title="Add a tag to this topic"&gt;Add a tag&lt;/a&gt;&lt;br /&gt;    &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &lt;span id="ctl00_WikiContent_TopicTagEditor_editPanel" style="display:none" class="CCT_Edit"&gt;&lt;br /&gt;      &lt;input name="ctl00$WikiContent$TopicTagEditor$textbox" type="text" id="ctl00_WikiContent_TopicTagEditor_textbox" class="CCT_TextBox" autocomplete="off" /&gt;&lt;br /&gt;      &lt;a href="../../Platform/Controls/CCTagEditor/#" id="ctl00_WikiContent_TopicTagEditor_addLink" class="CCT_LinkButton" onclick="return CCT_AddTags(-1);" title="Submit the tags for this topic"&gt;Add&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;      &amp;nbsp;&lt;br /&gt;      &lt;a href="../../Platform/Controls/CCTagEditor/#" id="ctl00_WikiContent_TopicTagEditor_cancelLink" class="CCT_LinkButton" onclick="return CCT_CancelAddTag(-1);" title="Cancel this operation"&gt;Cancel&lt;/a&gt;&lt;br /&gt;    &lt;/span&gt;&lt;br /&gt;    &lt;span id="ctl00_WikiContent_TopicTagEditor_messagePanel" class="CCT_Message"&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;  &lt;div id="ctl00_WikiContent_TopicTagEditor_flagAsPanel" class="CCT_FlagAsPanel" style="display:none"&gt;    &lt;span id="ctl00_WikiContent_TopicTagEditor_flagAsLabel"&gt;Flag as &lt;/span&gt;&lt;br /&gt;    &lt;a href="../../Platform/Controls/CCTagEditor/#" id="ctl00_WikiContent_TopicTagEditor_contentBugLink" class="CCT_LinkButton" onclick="return CCT_FlagContentBug(&amp;quot;http://msdn.microsoft.com/en-us/library/Community-Signup.aspx?ru=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fbhc3fa7f(VS.90).aspx&amp;quot;,-1);" title="Flagging this annotation as a 'ContentBug' will let the author know that this topic needs to be reviewed"&gt;ContentBug&lt;/a&gt;&lt;br /&gt;  &lt;/div&gt;  &lt;div style="clear:both"&gt;&lt;/div&gt;&lt;/div&gt; &lt;br /&gt;  &lt;/div&gt; &lt;br /&gt;  &lt;div class="CCS_WikiLogo"&gt;   &lt;img id="ctl00_WikiContent_wikiLogo" class="LibC_wiki" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&lt;br /&gt;  &lt;/div&gt; &lt;br /&gt;  &lt;div id="ctl00_WikiContent_contentContainer" class="CCS_ContentContainer"&gt;    &lt;br /&gt;    &lt;div id="ctl00_WikiContent_headerContainer" class="CCS_HeaderContainer"&gt;     &lt;br /&gt;   &lt;table cellpadding="0" cellspacing="0" border="0" width="100%" class="CCS_Header"&gt;    &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;       &lt;div class="CCS_HeaderTitle"&gt;         &lt;span id="ctl00_WikiContent_headerTitle"&gt;Community Content&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;              &lt;a href="/platform/Controls/CCSection/resources/cchelp.htm" id="ctl00_WikiContent_helpLink" class="CCS_HelpLink" onclick="CCS_ShowHelp(&amp;quot;/platform/Controls/CCSection/resources/cchelp.htm&amp;quot;,400,400);return false;"&gt;&lt;img src="http://i.msdn.microsoft.com/Global/Images/clear.gif" id="ctl00_WikiContent_helpImage" class="CCS_HelpImage  LibC_help" alt="What is Community Content?" title="What is Community Content?" /&gt;&lt;/a&gt;&lt;br /&gt;       &lt;/div&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/table&gt;   &lt;table cellpadding="0" cellspacing="0" border="0" width="100%" class="CCS_Toolbar"&gt;    &lt;tr&gt;     &lt;td class="CCS_Add"&gt;&lt;br /&gt;       &lt;a id="ctl00_WikiContent_Add" class="CCS_Link" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&amp;quot;ctl00$WikiContent$Add&amp;quot;, &amp;quot;&amp;quot;, false, &amp;quot;&amp;quot;, &amp;quot;http://msdn.microsoft.com/en-us/library/Community-Signup.aspx?ru=http%253a%252f%252fmsdn.microsoft.com%252fen-us%252flibrary%252fbhc3fa7f(VS.90).aspx%253fwbi%253dnew&amp;quot;, false, true))"&gt;Add new content&lt;/a&gt;&lt;br /&gt;     &lt;/td&gt;     &lt;td class="CCS_RecentChanges"&gt;&lt;br /&gt;       &lt;a href="http://msdn.microsoft.com/en-us/library/community-edits.rss?topic=bhc3fa7f|en-us|90" id="ctl00_WikiContent_recentPageLink"&gt;&lt;img id="ctl00_WikiContent_imageRSS" class="CCS_RSSImage LibC_rss_button" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" alt="RSS" align="middle" style="border-width:0px;" /&gt;&lt;/a&gt;&amp;nbsp;&lt;br /&gt;       &lt;span id="ctl00_WikiContent_recentChangesTitle" class="CCS_RecentChangesText"&gt;Annotations&lt;/span&gt;&lt;br /&gt;     &lt;/td&gt;     &lt;td align="right" class="CCS_Profile"&gt;&lt;br /&gt;      &lt;br /&gt;     &lt;/td&gt;    &lt;/tr&gt;   &lt;/table&gt;    &lt;br /&gt;    &lt;/div&gt; &lt;br /&gt;    &lt;div id="ctl00_WikiContent_wikiItems" class="CCS_ItemsContainer"&gt;     &lt;div id="ctl00_WikiContent_ctl00_ItemUpdatePanel"&gt;      &lt;br /&gt;    &lt;div id="ctl00_WikiContent_ctl00_Container" class="CCI_Container" style="display:none;"&gt;       &lt;br /&gt;      &lt;div id="ctl00_WikiContent_ctl00_Header" class="CCI_Header"&gt;        &lt;br /&gt;        &lt;table width="100%" cellpadding="0" cellspacing="0"&gt;            &lt;tr&gt;                &lt;td align="left"&gt;&lt;br /&gt;                    &lt;span id="ctl00_WikiContent_ctl00_HeaderTitle" class="CCI_Header_Title"&gt;&lt;/span&gt;&lt;br /&gt;                &lt;/td&gt;                &lt;td&gt;&lt;br /&gt;                    &lt;span id="ctl00_WikiContent_ctl00_Label2" class="CCI_Header_Spacer"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;                &lt;/td&gt;                                   &lt;td align="right" class="CCI_Header_Actions"&gt;&lt;br /&gt;                      &lt;span id="ctl00_WikiContent_ctl00_EditInfo"&gt;&lt;/span&gt;&lt;span id="ctl00_WikiContent_ctl00_Separator"&gt;&lt;br /&gt;                        &amp;nbsp;&amp;nbsp;|&amp;nbsp;&amp;nbsp;&lt;br /&gt;                      &lt;/span&gt;&lt;span id="ctl00_WikiContent_ctl00_EditLabel"&gt;&lt;a id="ctl00_WikiContent_ctl00_Edit" title="Edit this version" class="CCI_Header_Link" href="javascript:__doPostBack('ctl00$WikiContent$ctl00$Edit','')"&gt;Edit&lt;/a&gt;&lt;/span&gt;&lt;input name="ctl00$WikiContent$ctl00$showhistoryFlag" type="text" id="ctl00_WikiContent_ctl00_showhistoryFlag" style="display: none" value="false" /&gt;&lt;br /&gt;                  &lt;/td&gt;                                            &lt;/tr&gt;        &lt;/table&gt;      &lt;br /&gt;       &lt;/div&gt; &lt;br /&gt;      &lt;br /&gt; &lt;br /&gt;      &lt;div id="ctl00_WikiContent_ctl00_EditorPanel" class="CCI_Text" style="cursor:default;"&gt;        &lt;br /&gt;        &lt;div id="ctl00_WikiContent_ctl00_Editor_Container" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl00_WikiContent_ctl00_Editor_Save')"&gt;         &lt;br /&gt;   &lt;br /&gt;    &lt;div id="ctl00_WikiContent_ctl00_Editor_RadEditor" title="Double-click to edit this block" class=" CCE_Editor_Disabled" style="width:680px;height:400px;height:auto;width:auto;"&gt;          &lt;!-- 2008.2.723.35 --&gt;&lt;br /&gt;         &lt;/div&gt;    &lt;input type="hidden" name="ctl00$WikiContent$ctl00$Editor$editorData" id="ctl00_WikiContent_ctl00_Editor_editorData" /&gt;&lt;br /&gt;    &lt;input type="hidden" name="ctl00$WikiContent$ctl00$Editor$tagEditorData" id="ctl00_WikiContent_ctl00_Editor_tagEditorData" /&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;  &lt;br /&gt;        &lt;/div&gt; &lt;br /&gt;      &lt;br /&gt;       &lt;/div&gt; &lt;br /&gt;      &lt;div id="ctl00_WikiContent_ctl00_TagEditor_panel" class="CCT_Panel"&gt;  &lt;div id="tagsPanel" class="CCT_TagsPanel"&gt;    &lt;span id="ctl00_WikiContent_ctl00_TagEditor_title" class="CCT_Title"&gt;Tags&lt;/span&gt;&lt;br /&gt;    &lt;a href="/platform/Controls/CCTagEditor/resources/taghelp.htm" id="ctl00_WikiContent_ctl00_TagEditor_helpLink" class="CCT_HelpLink" onclick="CCS_ShowHelp(&amp;quot;/platform/Controls/CCTagEditor/resources/taghelp.htm&amp;quot;,800,600);return false;"&gt;&lt;br /&gt;      &lt;img src="http://i.msdn.microsoft.com/Global/Images/clear.gif" id="ctl00_WikiContent_ctl00_TagEditor_helpImage" class="CCT_HelpImage LibC_help" alt="What's this?" title="What's this?" /&gt;&lt;/a&gt;:&lt;br /&gt;    &lt;span id="ctl00_WikiContent_ctl00_TagEditor_tags" class="CCT_Text"&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span id="ctl00_WikiContent_ctl00_TagEditor_view" class="CCT_View"&gt;&lt;br /&gt;      &lt;a href="../../Platform/Controls/CCTagEditor/#" id="ctl00_WikiContent_ctl00_TagEditor_addTagLink" class="CCT_LinkButton" title="Add a tag to this topic"&gt;Add a tag&lt;/a&gt;&lt;br /&gt;    &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &lt;span id="ctl00_WikiContent_ctl00_TagEditor_editPanel" style="display:none" class="CCT_Edit"&gt;&lt;br /&gt;      &lt;input name="ctl00$WikiContent$ctl00$TagEditor$textbox" type="text" id="ctl00_WikiContent_ctl00_TagEditor_textbox" class="CCT_TextBox" autocomplete="off" /&gt;&lt;br /&gt;      &lt;a href="../../Platform/Controls/CCTagEditor/#" id="ctl00_WikiContent_ctl00_TagEditor_addLink" class="CCT_LinkButton" title="Submit the tags for this topic"&gt;Add&lt;/a&gt;&lt;br /&gt; &lt;br /&gt;      &amp;nbsp;&lt;br /&gt;      &lt;a href="../../Platform/Controls/CCTagEditor/#" id="ctl00_WikiContent_ctl00_TagEditor_cancelLink" class="CCT_LinkButton" title="Cancel this operation"&gt;Cancel&lt;/a&gt;&lt;br /&gt;    &lt;/span&gt;&lt;br /&gt;    &lt;span id="ctl00_WikiContent_ctl00_TagEditor_messagePanel" class="CCT_Message"&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/div&gt;  &lt;div id="ctl00_WikiContent_ctl00_TagEditor_flagAsPanel" class="CCT_FlagAsPanel" style="display:none"&gt;    &lt;span id="ctl00_WikiContent_ctl00_TagEditor_flagAsLabel"&gt;Flag as &lt;/span&gt;&lt;br /&gt;    &lt;a href="../../Platform/Controls/CCTagEditor/#" id="ctl00_WikiContent_ctl00_TagEditor_contentBugLink" class="CCT_LinkButton" onclick="return CCT_FlagContentBug(&amp;quot;http://msdn.microsoft.com/en-us/library/Community-Signup.aspx?ru=http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fbhc3fa7f(VS.90).aspx&amp;quot;,-1);" title="Flagging this annotation as a 'ContentBug' will let the author know that this topic needs to be reviewed"&gt;ContentBug&lt;/a&gt;&lt;br /&gt;  &lt;/div&gt;  &lt;div style="clear:both"&gt;&lt;/div&gt;&lt;/div&gt; &lt;br /&gt; &lt;br /&gt;    &lt;br /&gt;      &lt;/div&gt;  &lt;br /&gt;     &lt;/div&gt; &lt;br /&gt;    &lt;/div&gt; &lt;br /&gt;    &lt;div id="ctl00_WikiContent_EditorPanel" class="CCI_Container_Edit" style="display:none"&gt;     &lt;br /&gt;      &lt;div id="ctl00_WikiContent_Editor_Container" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl00_WikiContent_Editor_Save')"&gt;      &lt;br /&gt;   &lt;br /&gt;    &lt;div id="ctl00_WikiContent_Editor_RadEditor" title="Double-click to edit this block" class=" CCE_Editor_Disabled" style="width:680px;height:400px;height:auto;width:auto;"&gt;       &lt;br /&gt;      &lt;/div&gt;    &lt;input type="hidden" name="ctl00$WikiContent$Editor$editorData" id="ctl00_WikiContent_Editor_editorData" /&gt;&lt;br /&gt;    &lt;input type="hidden" name="ctl00$WikiContent$Editor$tagEditorData" id="ctl00_WikiContent_Editor_tagEditorData" /&gt;&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;  &lt;br /&gt;     &lt;/div&gt; &lt;br /&gt;    &lt;br /&gt;    &lt;/div&gt;    &lt;br /&gt; &lt;br /&gt;    &lt;div id="ProgressIndicator" class="CCS_Progress"&gt;      &lt;img src="http://i.msdn.microsoft.com/Global/Images/clear.gif" id="ctl00_WikiContent_progressImage" class="LibC_spinner" alt="Processing" /&gt;&lt;br /&gt;    &lt;/div&gt; &lt;br /&gt;    &lt;div class="CCS_Footer"&gt;&lt;/div&gt;   &lt;br /&gt;   &lt;/div&gt; &lt;br /&gt;  &lt;/div&gt;      &lt;br /&gt; &lt;br /&gt;&lt;div style="overflow:hidden;display:block;position:relative;"&gt;&lt;table cellpadding="0" cellspacing="0" border="0" width="100%"&gt;  &lt;tr&gt;    &lt;td id="ctl00_mtpsFooter_FooterFadeCell" class="MTPS_FooterFade"&gt;&lt;br /&gt;      &lt;div id="ctl00_mtpsFooter_SiteLinks" class="MTPS_FooterLinks"&gt; &lt;br /&gt;  &lt;/div&gt;      &lt;span id="ctl00_mtpsFooter_MSFT_copyright" title="© 2010  Microsoft Corporation. All rights reserved." class="MTPS_FooterCopyright"&gt;&amp;copy; 2010  Microsoft Corporation. All rights reserved.&lt;/span&gt;&lt;br /&gt;      &lt;a id="ctl00_mtpsFooter_MSFT_Terms" title="Terms of Use" class="MTPS_FooterLinks" href="/cc300389.aspx"&gt;Terms of Use&lt;/a&gt;&lt;br /&gt;      &lt;span id="ctl00_mtpsFooter_PipeSpan1"&gt;|&lt;/span&gt;&lt;br /&gt;      &lt;a id="ctl00_mtpsFooter_MSFT_Trademarks" title="Trademarks" class="MTPS_FooterLinks" href="http://www.microsoft.com/library/toolbar/3.0/trademarks/en-us.mspx"&gt;Trademarks&lt;/a&gt;&lt;br /&gt;      &lt;span id="ctl00_mtpsFooter_PipeSpan2"&gt;|&lt;/span&gt;&lt;br /&gt;      &lt;a id="ctl00_mtpsFooter_MSFT_PrivacyStatement" title="Privacy Statement" class="MTPS_FooterLinks" href="http://www.microsoft.com/info/privacy.mspx"&gt;Privacy Statement&lt;/a&gt;&lt;br /&gt;      &lt;br /&gt;      &lt;a id="ctl00_mtpsFooter_MSFT_Feedback" class="MTPS_FooterLinks" rel="sitefeedback" target="_blank"&gt;&lt;/a&gt;&lt;br /&gt;    &lt;/td&gt;      &lt;td id="ctl00_mtpsFooter_FooterLogoCell"&gt;&lt;br /&gt;      &lt;a id="ctl00_mtpsFooter_MSFT_LOGO" title="Microsoft Corporation" href="http://www.microsoft.com/en/us/default.aspx"&gt;&lt;img id="ctl00_mtpsFooter_MSFT_imgLogo" class="msdn_TabC_mslogo" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width:0px;" /&gt;&lt;/a&gt;&lt;br /&gt;    &lt;/td&gt;    &lt;/tr&gt;&lt;/table&gt; &lt;br /&gt;&lt;/div&gt; &lt;br /&gt;      &lt;br /&gt; &lt;/div&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;div style="display:none"&gt;&lt;img src="http://c.microsoft.com/trans_pixel.asp?source=msdn&amp;amp;TYPE=PV&amp;amp;uri=%2fen-us%2flibrary(d%3ddefault)%2fbhc3fa7f(l%3den-us%2cv%3dVS.90).aspx&amp;amp;p=_en-us_library(d=default)_bhc3fa7f(l=en-us,v=VS.90).aspx&amp;amp;r=http%3a%2f%2fwww.google.nl%2furl%3fsa%3dt%26source%3dweb%26ct%3dres%26cd%3d1%26ved%3d0CAYQFjAA%26url%3dhttp%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fbhc3fa7f.aspx%26rct%3dj%26q%3dNew%2bprogramming%2blanguage%2busing%2bCLS%26ei%3dYfyVS8eSIKP40wTF87HvCw%26usg%3dAFQjCNHGK_ffsBKHNiVR7IwROSWZ1rig-w" width="0" height="0" hspace="0" vspace="0" border="0" alt="Page view tracker" /&gt;&lt;/div&gt;  &lt;br /&gt;&lt;script src="http://i2.msdn.microsoft.com/platform/Controls/WebTrends/resources/webtrendsscript-bn20100217.js" type="text/javascript"&gt;&lt;/script&gt;&lt;br /&gt;&lt;noscript&gt;&lt;br /&gt;&lt;div&gt;&lt;img alt="DCSIMG" id="Img1" width="1" height="1" src="http://m.webtrends.com/dcsmgru7m99k7mqmgrhudo0k8_8c6m/njs.gif?dcsuri=/nojavascript&amp;amp;WT.js=No" /&gt;&lt;/div&gt;&lt;/noscript&gt;&lt;br /&gt;  &lt;script type="text/javascript" src="http://i2.msdn.microsoft.com/en-us/library/mtps-bn20100217.js?l=en-us&amp;amp;i=library&amp;amp;ct=AlternateSelector;CCEditor;CCItem;CCSection;CCTagEditor;CodeSnippet;CollapsibleArea;ContentFallback;DropDownFilter;ExpandCollapseAll;Eyebrow;Footer;InstrumentedLink;InteractiveToolbar;iRootBrand;LocaleManagementFlyout;lwViewSwitcher;MastheadLibrary;MemberlistFrameworksFilter;MemberlistMembersFilter;MtpsLoginStatus;MtpsRating;MtViewDropDown;Omniture;RedVelvetCodeSnippet;RedVelvetCollapsibleArea;RedVelvetInstrumentedLink;RelatedPages;ResizeableAreaD10;StoSearch;StoTabStripLibrary;SurveyLauncher;TagCloud;TemplatedFlyout;Tickler;Toc;UserRecognition;UserRecognition_Flyout;UserRecognition_RemoveAnonymousProfile;WebMetrix;WebTrends"&gt;&lt;/script&gt;&lt;br /&gt;    &lt;script type="text/javascript"&gt;        //&lt;![CDATA[        setTimeout(function() {            var hashElementId = document.location.hash.substr(1);            var hashElement = document.getElementById(hashElementId);            if (hashElement != null) {                hashElement.scrollIntoView(true);            }        }, 1);        //]]&gt;    &lt;/script&gt;&lt;br /&gt;  &lt;br /&gt;&lt;script type="text/javascript"&gt; //&lt;![CDATA[var CCT_Controls =  new Array({id:-1,prefix:'ctl00_WikiContent_TopicTagEditor_'}, {id:-2,prefix:'ctl00_WikiContent_ctl00_TagEditor_'});var CCE_EditorInfo =  new Array({i:-2,p:'ctl00_WikiContent_ctl00_Editor_',c:'ctl00_WikiContent_ctl00_'}, {i:-1,p:'ctl00_WikiContent_Editor_',c:''});//]]&gt;&lt;/script&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;script type="text/javascript"&gt; //&lt;![CDATA[Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(CCS_BeginRequestHandler);Sys.WebForms.PageRequestManager.getInstance().add_endRequest(CCS_EndRequestHandler); RegisterAutoSubmit('ctl00_ib1_Flyout_Rating1','ctl00_ib1_Flyout_btnSend','contentRatingbhc3fa7fVS.90en-us'); //]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript" language="javascript"&gt; &lt;!-- function GetContentWnd(){ return parent; } function OnInitPage(){var oWnd = GetContentWnd();} function OnSave(){ var oWnd = GetContentWnd(); window.external.addFavorite('http://msdn.microsoft.com/en-us/library/bhc3fa7f.aspx', oWnd.document.title ); } --&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt; //&lt;![CDATA[document.getElementById('ctl00_ib1_Flyout_rtgContainer').title="Click a star and provide feedback";CCT_Init("false","http%3a%2f%2fmsdn.microsoft.com%2fen-us%2flibrary%2fbhc3fa7f.aspx");$addHandler($get("ctl00_WikiContent_TopicTagEditor_editPanel"),"keydown",CCT_KeyDown);Sys.Application.initialize();TFly_Init('ctl00_ctl09_LocaleManagement_ctl00',0,0,1,0,0,'LocaleManagementFlyoutStaticHover','',0,400,'','','','');TFly_Init('ctl00_ib1_Flyout',5,2,1,0,0,'','',0,400,'','TFlyPreAnimate','','');MTPS.Controls.MtpsRating.createMtpsRating('ctl00_ib1_Flyout_Rating1','ratingStar','filledRatingStar','emptyRatingStar','savedRatingStar','5','LeftToRightTopToBottom', false);MTPS.Controls.ResizeableArea = new MTPS.Controls.CreateResizeableArea('ctl00_LibFrame','ctl00_raSplitter','ctl00_raLeft','ctl00_raRight','tocwidth','toccollapsed','173');var tocVectorObject;var hostbase;var closedImg;var openImg;var emptyImg;var loadingImg;var tocVector;var tocIndex = 0;var holder;var tocLoaded = false;var tocCollapsed = 'False';tocVectorObject = {"nodes": [{"id": "ms310241(n)" ,"url": "/ms310241(n)"},{"id": "aa187916(n)" ,"url": "/aa187916(n)"},{"id": "aa187919(n)" ,"url": "/aa187919(n)"},{"id": "bb400865(n)" ,"url": "/bb400865(n)"},{"id": "ms299694(n)" ,"url": "/ms299694(n)"},{"id": "ms298723(n)" ,"url": "/ms298723(n)"},{"id": "ms298739(n)" ,"url": "/ms298739(n)"},{"id": "bhc3fa7f(n)" ,"url": "/bhc3fa7f(n)"}]};hostbase ="http://msdn.microsoft.com/en-us/library";tocVector = eval(tocVectorObject);closedImg = "LibC_c";openImg = "LibC_o";emptyImg = "LibC_e";var tocDir = false;TFly_Init('ctl00_eb1_ctl00',0,-1,-1,0,0,'statHover','',0,0,'EyeBrowMenuBarSetHeight','ExpEye','','');TFly_Init('ctl00_eb1_ctl01',0,-1,-1,0,0,'statHover','',0,0,'EyeBrowMenuBarSetHeight','ExpEye','','');TFly_Init('ctl00_eb1_ctl02',0,-1,-1,0,0,'statHover','',0,0,'EyeBrowMenuBarSetHeight','ExpEye','','');TFly_Init('ctl00_eb1_ctl03',0,-1,-1,0,0,'statHover','',0,0,'EyeBrowMenuBarSetHeight','ExpEye','','');TFly_Init('ctl00_eb1_ctl04',0,-1,-1,0,0,'statHover','',0,0,'EyeBrowMenuBarSetHeight','ExpEye','','');TFly_Init('ctl00_eb1_ctl05',0,-1,-1,0,0,'statHover','',0,0,'EyeBrowMenuBarSetHeight','ExpEye','','');TFly_Init('ctl00_eb1_ctl06',0,-1,-1,0,0,'statHover','',0,0,'EyeBrowMenuBarSetHeight','ExpEye','','');TFly_Init('ctl00_eb1_ctl07',0,-1,-1,0,0,'statHover','',0,0,'EyeBrowMenuBarSetHeight','ExpEye','','');CheckDropDownClientCookie(false);SetFilterText(false);//]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-5519318198231680508?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/5519318198231680508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=5519318198231680508' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5519318198231680508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5519318198231680508'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/writing-cls-compliant-code.html' title='Writing CLS-Compliant Code'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-2654057438265508581</id><published>2010-03-09T00:52:00.000-08:00</published><updated>2010-03-09T02:18:32.445-08:00</updated><title type='text'>BackgroundWorker Class</title><content type='html'>&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;Visual Basic (Declaration)&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl00_code" space="preserve"&gt;&amp;lt;HostProtectionAttribute(SecurityAction.LinkDemand, SharedState := &lt;span style="color: blue;"&gt;True&lt;/span&gt;)&amp;gt; _&lt;br /&gt;&lt;span style="color: blue;"&gt;Public&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt; BackgroundWorker _&lt;br /&gt;    &lt;span style="color: blue;"&gt;Inherits&lt;/span&gt; Component&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;Visual Basic (Usage)&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl01_VisualBasicUsage"&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl01_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; instance &lt;span style="color: blue;"&gt;As&lt;/span&gt; BackgroundWorker&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;C#&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl02_CSharp"&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl02_code" space="preserve"&gt;[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = &lt;span style="color: blue;"&gt;true&lt;/span&gt;)]&lt;br /&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; BackgroundWorker : Component&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Visual C++&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl03_ManagedCPlusPlus"&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl03_code" space="preserve"&gt;[HostProtectionAttribute(SecurityAction::LinkDemand, SharedState = &lt;span style="color: blue;"&gt;true&lt;/span&gt;)]&lt;br /&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; ref &lt;span style="color: blue;"&gt;class&lt;/span&gt; BackgroundWorker : &lt;span style="color: blue;"&gt;public&lt;/span&gt; Component&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;JScript&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl04_JScript"&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl56_ctl00_ctl04_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; BackgroundWorker &lt;span style="color: blue;"&gt;extends&lt;/span&gt; Component&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="CollapseRegionLink"&gt;&amp;nbsp;Remarks&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;&lt;div class="alert"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;&lt;img alt="Note" src="http://i.msdn.microsoft.com/4852et58.alert_note(en-us,VS.90).gif" /&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;The &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.permissions.hostprotectionattribute.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl01" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl01',this);"&gt;HostProtectionAttribute&lt;/a&gt; attribute applied to this type or member has the following &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.permissions.hostprotectionattribute.resources.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl02" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl02',this);"&gt;Resources&lt;/a&gt; property value: &lt;strong&gt;SharedState&lt;/strong&gt;. The &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.permissions.hostprotectionattribute.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl03" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl03',this);"&gt;HostProtectionAttribute&lt;/a&gt; does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.permissions.hostprotectionattribute.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl04" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl04',this);"&gt;HostProtectionAttribute&lt;/a&gt; class or &lt;a href="http://msdn.microsoft.com/en-us/library/ms172338.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl05" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl05',this);"&gt;SQL Server Programming and Host Protection Attributes&lt;/a&gt;.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;The &lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt; class allows you to run an operation on a separate, dedicated thread. Time-consuming operations like downloads and database transactions can cause your user interface (UI) to seem as though it has stopped responding while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the &lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt; class provides a convenient solution.&lt;br /&gt;To execute a time-consuming operation in the background, create a &lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt; and listen for events that report the progress of your operation and signal when your operation is finished. You can create the &lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt; programmatically or you can drag it onto your form from the &lt;span class="label"&gt;Components&lt;/span&gt; tab of the &lt;span class="label"&gt;Toolbox&lt;/span&gt;. If you create the &lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt; in the Windows Forms Designer, it will appear in the Component Tray, and its properties will be displayed in the Properties window.&lt;br /&gt;To set up for a background operation, add an event handler for the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl06" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl06',this);"&gt;DoWork&lt;/a&gt; event. Call your time-consuming operation in this event handler. To start the operation, call &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.runworkerasync.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl07" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl07',this);"&gt;RunWorkerAsync&lt;/a&gt;. To receive notifications of progress updates, handle the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.progresschanged.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl08" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl08',this);"&gt;ProgressChanged&lt;/a&gt; event. To receive a notification when the operation is completed, handle the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.runworkercompleted.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl09" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl09',this);"&gt;RunWorkerCompleted&lt;/a&gt; event.&lt;br /&gt;&lt;div class="alert"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;&lt;img alt="Note" src="http://i.msdn.microsoft.com/4852et58.alert_note(en-us,VS.90).gif" /&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;You must be careful not to manipulate any user-interface objects in your &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl11" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl11',this);"&gt;DoWork&lt;/a&gt; event handler. Instead, communicate to the user interface through the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.progresschanged.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl12" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl12',this);"&gt;ProgressChanged&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.runworkercompleted.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl13" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl13',this);"&gt;RunWorkerCompleted&lt;/a&gt; events.&lt;br /&gt;&lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt; events are not marshaled across &lt;a href="http://msdn.microsoft.com/en-us/library/system.appdomain.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl14" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl14',this);"&gt;AppDomain&lt;/a&gt; boundaries. Do not use a &lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt; component to perform multithreaded operations in more than one &lt;a href="http://msdn.microsoft.com/en-us/library/system.appdomain.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl15" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl15',this);"&gt;AppDomain&lt;/a&gt;.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;If your background operation requires a parameter, call &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.runworkerasync.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl16" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl16',this);"&gt;RunWorkerAsync&lt;/a&gt; with your parameter. Inside the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl17" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl17',this);"&gt;DoWork&lt;/a&gt; event handler, you can extract the parameter from the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.doworkeventargs.argument.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl18" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl18',this);"&gt;DoWorkEventArgs&lt;span class="cs"&gt;.&lt;/span&gt;&lt;span class="vb"&gt;.&lt;/span&gt;&lt;span class="cpp"&gt;::&lt;/span&gt;&lt;span class="nu"&gt;.&lt;/span&gt;Argument&lt;/a&gt; property.&lt;br /&gt;For more information about &lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt;, see &lt;a href="http://msdn.microsoft.com/en-us/library/hybbz6ke.aspx" id="ctl00_MTCS_main_ctl57_ctl00_ctl19" onclick="javascript:Track('ctl00_MTCS_main_ctl57_ctl00_contenthere|ctl00_MTCS_main_ctl57_ctl00_ctl19',this);"&gt;How to: Run an Operation in the Background&lt;/a&gt;.&lt;br /&gt;&lt;span errorurl="" filtername="" filterstring="" indexmoniker="!DefaultDynamicLinkIndex"&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="CollapseRegionLink"&gt;&amp;nbsp;Examples&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;&lt;a href="http://www.blogger.com/" id="exampleToggle"&gt;&lt;/a&gt;&lt;br /&gt;The following code example demonstrates the use of the &lt;span class="selflink"&gt;BackgroundWorker&lt;/span&gt; class for executing a time-consuming operation asynchronously. The operation computes the selected Fibonacci number, reports progress updates as the calculation proceeds, and permits a pending calculation to be canceled.&lt;br /&gt;&lt;div id="snippetGroup"&gt;&lt;span id="ctl00_MTCS_main_ctl58_ctl00_ctl00"&gt;&lt;/span&gt;&lt;span id="ctl00_MTCS_main_ctl58_ctl00_ctl01"&gt;&lt;/span&gt;&lt;span id="ctl00_MTCS_main_ctl58_ctl00_ctl02"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl58_ctl00_ctl00_VisualBasic"&gt;&lt;br /&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;Visual Basic&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl58_ctl00_ctl00_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System&lt;br /&gt;&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System.Collections&lt;br /&gt;&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System.ComponentModel&lt;br /&gt;&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System.Drawing&lt;br /&gt;&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System.Threading&lt;br /&gt;&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System.Windows.Forms&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;Public&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt; FibonacciForm&lt;br /&gt;    &lt;span style="color: blue;"&gt;Inherits&lt;/span&gt; System.Windows.Forms.Form&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; numberToCompute &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt; = 0&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; highestPercentageReached &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt; = 0&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; numericUpDown1 &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Windows.Forms.NumericUpDown&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;WithEvents&lt;/span&gt; startAsyncButton &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Windows.Forms.Button&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;WithEvents&lt;/span&gt; cancelAsyncButton &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Windows.Forms.Button&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; progressBar1 &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Windows.Forms.ProgressBar&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; resultLabel &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Windows.Forms.Label&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;WithEvents&lt;/span&gt; backgroundWorker1 &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.ComponentModel.BackgroundWorker&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;Public&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; &lt;span style="color: blue;"&gt;New&lt;/span&gt;()&lt;br /&gt;        InitializeComponent()&lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; &lt;span style="color: green;"&gt;'New&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; startAsyncButton_Click(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Object, _&lt;br /&gt;    &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.EventArgs) _&lt;br /&gt;    &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; startAsyncButton.Click&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Reset the text in the result label.&lt;/span&gt;&lt;br /&gt;        resultLabel.Text = [String].Empty&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Disable the UpDown control until &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' the asynchronous operation is done.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.Enabled = &lt;span style="color: blue;"&gt;False&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Disable the Start button until &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' the asynchronous operation is done.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.startAsyncButton.Enabled = &lt;span style="color: blue;"&gt;False&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Enable the Cancel button while &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' the asynchronous operation runs.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton.Enabled = &lt;span style="color: blue;"&gt;True&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Get the value from the UpDown control.&lt;/span&gt;&lt;br /&gt;        numberToCompute = CInt(numericUpDown1.Value)&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Reset the variable for percentage tracking.&lt;/span&gt;&lt;br /&gt;        highestPercentageReached = 0&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Start the asynchronous operation.&lt;/span&gt;&lt;br /&gt;        backgroundWorker1.RunWorkerAsync(numberToCompute)&lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; &lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; cancelAsyncButton_Click( _&lt;br /&gt;    &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Object, _&lt;br /&gt;    &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.EventArgs) _&lt;br /&gt;    &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; cancelAsyncButton.Click&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Cancel the asynchronous operation.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.backgroundWorker1.CancelAsync()&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Disable the Cancel button.&lt;/span&gt;&lt;br /&gt;        cancelAsyncButton.Enabled = &lt;span style="color: blue;"&gt;False&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; &lt;span style="color: green;"&gt;'cancelAsyncButton_Click&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: green;"&gt;' This event handler is where the actual work is done.&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; backgroundWorker1_DoWork( _&lt;br /&gt;    &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, _&lt;br /&gt;    &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; DoWorkEventArgs) _&lt;br /&gt;    &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; backgroundWorker1.DoWork&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Get the BackgroundWorker object that raised this event.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; worker &lt;span style="color: blue;"&gt;As&lt;/span&gt; BackgroundWorker = _&lt;br /&gt;            CType(sender, BackgroundWorker)&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Assign the result of the computation&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' to the Result property of the DoWorkEventArgs&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' object. This is will be available to the &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' RunWorkerCompleted eventhandler.&lt;/span&gt;&lt;br /&gt;        e.Result = ComputeFibonacci(e.Argument, worker, e)&lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; &lt;span style="color: green;"&gt;'backgroundWorker1_DoWork&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: green;"&gt;' This event handler deals with the results of the&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: green;"&gt;' background operation.&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; backgroundWorker1_RunWorkerCompleted( _&lt;br /&gt;    &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; RunWorkerCompletedEventArgs) _&lt;br /&gt;    &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; backgroundWorker1.RunWorkerCompleted&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' First, handle the case where an exception was thrown.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;If&lt;/span&gt; (e.Error IsNot &lt;span style="color: blue;"&gt;Nothing&lt;/span&gt;) &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;            MessageBox.Show(e.Error.Message)&lt;br /&gt;        &lt;span style="color: blue;"&gt;ElseIf&lt;/span&gt; e.Cancelled &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;' Next, handle the case where the user canceled the &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;' operation.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;' Note that due to a race condition in &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;' the DoWork event handler, the Cancelled&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;' flag may not have been set, even though&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;' CancelAsync was called.&lt;/span&gt;&lt;br /&gt;            resultLabel.Text = &lt;span style="color: maroon;"&gt;"Canceled"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Else&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;' Finally, handle the case where the operation succeeded.&lt;/span&gt;&lt;br /&gt;            resultLabel.Text = e.Result.ToString()&lt;br /&gt;        &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Enable the UpDown control.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.Enabled = &lt;span style="color: blue;"&gt;True&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Enable the Start button.&lt;/span&gt;&lt;br /&gt;        startAsyncButton.Enabled = &lt;span style="color: blue;"&gt;True&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Disable the Cancel button.&lt;/span&gt;&lt;br /&gt;        cancelAsyncButton.Enabled = &lt;span style="color: blue;"&gt;False&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; &lt;span style="color: green;"&gt;'backgroundWorker1_RunWorkerCompleted&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: green;"&gt;' This event handler updates the progress bar.&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; backgroundWorker1_ProgressChanged( _&lt;br /&gt;    &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; sender &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Object&lt;/span&gt;, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; ProgressChangedEventArgs) _&lt;br /&gt;    &lt;span style="color: blue;"&gt;Handles&lt;/span&gt; backgroundWorker1.ProgressChanged&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.progressBar1.Value = e.ProgressPercentage&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: green;"&gt;' This is the method that does the actual work. For this&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: green;"&gt;' example, it computes a Fibonacci number and&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: green;"&gt;' reports progress as it does its work.&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue;"&gt;Function&lt;/span&gt; ComputeFibonacci( _&lt;br /&gt;        &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; n &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt;, _&lt;br /&gt;        &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; worker &lt;span style="color: blue;"&gt;As&lt;/span&gt; BackgroundWorker, _&lt;br /&gt;        &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; e &lt;span style="color: blue;"&gt;As&lt;/span&gt; DoWorkEventArgs) &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Long&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' The parameter n must be &amp;gt;= 0 and &amp;lt;= 91.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' Fib(n), with n &amp;gt; 91, overflows a long.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;If&lt;/span&gt; n &amp;lt; 0 &lt;span style="color: blue;"&gt;OrElse&lt;/span&gt; n &amp;gt; 91 &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;Throw&lt;/span&gt; &lt;span style="color: blue;"&gt;New&lt;/span&gt; ArgumentException( _&lt;br /&gt;                &lt;span style="color: maroon;"&gt;"value must be &amp;gt;= 0 and &amp;lt;= 91"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"n"&lt;/span&gt;)&lt;br /&gt;        &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; result &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Long&lt;/span&gt; = 0&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;' Abort the operation if the user has canceled.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' Note that a call to CancelAsync may have set &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' CancellationPending to true just after the&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' last invocation of this method exits, so this &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' code will not have the opportunity to set the &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' DoWorkEventArgs.Cancel flag to true. This means&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' that RunWorkerCompletedEventArgs.Cancelled will&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' not be set to true in your RunWorkerCompleted&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;' event handler. This is a race condition.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;If&lt;/span&gt; worker.CancellationPending &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;            e.Cancel = &lt;span style="color: blue;"&gt;True&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Else&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;If&lt;/span&gt; n &amp;lt; 2 &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;                result = 1&lt;br /&gt;            &lt;span style="color: blue;"&gt;Else&lt;/span&gt;&lt;br /&gt;                result = ComputeFibonacci(n - 1, worker, e) + _&lt;br /&gt;                         ComputeFibonacci(n - 2, worker, e)&lt;br /&gt;            &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;' Report progress as a percentage of the total task.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; percentComplete &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt; = _&lt;br /&gt;                CSng(n) / CSng(numberToCompute) * 100&lt;br /&gt;            &lt;span style="color: blue;"&gt;If&lt;/span&gt; percentComplete &amp;gt; highestPercentageReached &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;                highestPercentageReached = percentComplete&lt;br /&gt;                worker.ReportProgress(percentComplete)&lt;br /&gt;            &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue;"&gt;Return&lt;/span&gt; result&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Function&lt;/span&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; InitializeComponent()&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1 = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Windows.Forms.NumericUpDown&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.startAsyncButton = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Windows.Forms.Button&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Windows.Forms.Button&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Windows.Forms.Label&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.progressBar1 = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Windows.Forms.ProgressBar&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.backgroundWorker1 = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.ComponentModel.BackgroundWorker&lt;br /&gt;        CType(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.SuspendLayout()&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'numericUpDown1&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.Location = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Point(16, 16)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.Maximum = &lt;span style="color: blue;"&gt;New&lt;/span&gt; &lt;span style="color: blue;"&gt;Decimal&lt;/span&gt;(&lt;span style="color: blue;"&gt;New&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt;() {91, 0, 0, 0})&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.Minimum = &lt;span style="color: blue;"&gt;New&lt;/span&gt; &lt;span style="color: blue;"&gt;Decimal&lt;/span&gt;(&lt;span style="color: blue;"&gt;New&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt;() {1, 0, 0, 0})&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.Name = &lt;span style="color: maroon;"&gt;"numericUpDown1"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.Size = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Size(80, 20)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.TabIndex = 0&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1.Value = &lt;span style="color: blue;"&gt;New&lt;/span&gt; &lt;span style="color: blue;"&gt;Decimal&lt;/span&gt;(&lt;span style="color: blue;"&gt;New&lt;/span&gt; &lt;span style="color: blue;"&gt;Integer&lt;/span&gt;() {1, 0, 0, 0})&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'startAsyncButton&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.startAsyncButton.Location = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Point(16, 72)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.startAsyncButton.Name = &lt;span style="color: maroon;"&gt;"startAsyncButton"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.startAsyncButton.Size = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Size(120, 23)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.startAsyncButton.TabIndex = 1&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.startAsyncButton.Text = &lt;span style="color: maroon;"&gt;"Start Async"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'cancelAsyncButton&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton.Enabled = &lt;span style="color: blue;"&gt;False&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton.Location = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Point(153, 72)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton.Name = &lt;span style="color: maroon;"&gt;"cancelAsyncButton"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton.Size = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Size(119, 23)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton.TabIndex = 2&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton.Text = &lt;span style="color: maroon;"&gt;"Cancel Async"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'resultLabel&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel.Location = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Point(112, 16)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel.Name = &lt;span style="color: maroon;"&gt;"resultLabel"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel.Size = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Size(160, 23)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel.TabIndex = 3&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel.Text = &lt;span style="color: maroon;"&gt;"(no result)"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'progressBar1&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.progressBar1.Location = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Point(18, 48)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.progressBar1.Name = &lt;span style="color: maroon;"&gt;"progressBar1"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.progressBar1.Size = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Size(256, 8)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.progressBar1.TabIndex = 4&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'backgroundWorker1&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.backgroundWorker1.WorkerReportsProgress = &lt;span style="color: blue;"&gt;True&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.backgroundWorker1.WorkerSupportsCancellation = &lt;span style="color: blue;"&gt;True&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'FibonacciForm&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;'&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.ClientSize = &lt;span style="color: blue;"&gt;New&lt;/span&gt; System.Drawing.Size(292, 118)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.progressBar1)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.resultLabel)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.cancelAsyncButton)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.startAsyncButton)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1)&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Name = &lt;span style="color: maroon;"&gt;"FibonacciForm"&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Text = &lt;span style="color: maroon;"&gt;"Fibonacci Calculator"&lt;/span&gt;&lt;br /&gt;        CType(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.numericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()&lt;br /&gt;        &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.ResumeLayout(&lt;span style="color: blue;"&gt;False&lt;/span&gt;)&lt;br /&gt; &lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; &lt;span style="color: green;"&gt;'InitializeComponent&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;    &amp;lt;STAThread()&amp;gt; _&lt;br /&gt;    &lt;span style="color: blue;"&gt;Shared&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; Main()&lt;br /&gt;        Application.Run(&lt;span style="color: blue;"&gt;New&lt;/span&gt; FibonacciForm)&lt;br /&gt;    &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; &lt;span style="color: green;"&gt;'Main&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt; &lt;span style="color: green;"&gt;'FibonacciForm &lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl58_ctl00_ctl01_CSharp"&gt;&lt;br /&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl58_ctl00_ctl01_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Collections;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.ComponentModel;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Drawing;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Threading;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Windows.Forms;&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; BackgroundWorkerExample&lt;br /&gt;{    &lt;br /&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; FibonacciForm : System.Windows.Forms.Form&lt;br /&gt;    {    &lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; numberToCompute = 0;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; highestPercentageReached = 0;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; System.Windows.Forms.NumericUpDown numericUpDown1;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; System.Windows.Forms.Button startAsyncButton;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; System.Windows.Forms.Button cancelAsyncButton;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; System.Windows.Forms.ProgressBar progressBar1;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; System.Windows.Forms.Label resultLabel;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; System.ComponentModel.BackgroundWorker backgroundWorker1;&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue;"&gt;public&lt;/span&gt; FibonacciForm()&lt;br /&gt;        {    &lt;br /&gt;            InitializeComponent();&lt;br /&gt; &lt;br /&gt;            InitializeBackgroundWorker();&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;// Set up the BackgroundWorker object by &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;// attaching event handlers. &lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; InitializeBackgroundWorker()&lt;br /&gt;        {&lt;br /&gt;            backgroundWorker1.DoWork += &lt;br /&gt;                &lt;span style="color: blue;"&gt;new&lt;/span&gt; DoWorkEventHandler(backgroundWorker1_DoWork);&lt;br /&gt;            backgroundWorker1.RunWorkerCompleted += &lt;br /&gt;                &lt;span style="color: blue;"&gt;new&lt;/span&gt; RunWorkerCompletedEventHandler(&lt;br /&gt;            backgroundWorker1_RunWorkerCompleted);&lt;br /&gt;            backgroundWorker1.ProgressChanged += &lt;br /&gt;                &lt;span style="color: blue;"&gt;new&lt;/span&gt; ProgressChangedEventHandler(&lt;br /&gt;            backgroundWorker1_ProgressChanged);&lt;br /&gt;        }&lt;br /&gt;    &lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; startAsyncButton_Click(System.Object sender, &lt;br /&gt;            System.EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: green;"&gt;// Reset the text in the result label.&lt;/span&gt;&lt;br /&gt;            resultLabel.Text = String.Empty;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Disable the UpDown control until &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// the asynchronous operation is done.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Disable the Start button until &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// the asynchronous operation is done.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton.Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Enable the Cancel button while &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// the asynchronous operation runs.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton.Enabled = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Get the value from the UpDown control.&lt;/span&gt;&lt;br /&gt;            numberToCompute = (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)numericUpDown1.Value;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Reset the variable for percentage tracking.&lt;/span&gt;&lt;br /&gt;            highestPercentageReached = 0;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Start the asynchronous operation.&lt;/span&gt;&lt;br /&gt;            backgroundWorker1.RunWorkerAsync(numberToCompute);&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; cancelAsyncButton_Click(System.Object sender, &lt;br /&gt;            System.EventArgs e)&lt;br /&gt;        {   &lt;br /&gt;            &lt;span style="color: green;"&gt;// Cancel the asynchronous operation.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.backgroundWorker1.CancelAsync();&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Disable the Cancel button.&lt;/span&gt;&lt;br /&gt;            cancelAsyncButton.Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;// This event handler is where the actual,&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;// potentially time-consuming work is done.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; backgroundWorker1_DoWork(object sender, &lt;br /&gt;            DoWorkEventArgs e)&lt;br /&gt;        {   &lt;br /&gt;            &lt;span style="color: green;"&gt;// Get the BackgroundWorker that raised this event.&lt;/span&gt;&lt;br /&gt;            BackgroundWorker worker = sender as BackgroundWorker;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Assign the result of the computation&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// to the Result property of the DoWorkEventArgs&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// object. This is will be available to the &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// RunWorkerCompleted eventhandler.&lt;/span&gt;&lt;br /&gt;            e.Result = ComputeFibonacci((&lt;span style="color: blue;"&gt;int&lt;/span&gt;)e.Argument, worker, e);&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;// This event handler deals with the results of the&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;// background operation.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; backgroundWorker1_RunWorkerCompleted(&lt;br /&gt;            object sender, RunWorkerCompletedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: green;"&gt;// First, handle the case where an exception was thrown.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.Error != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;br /&gt;            {&lt;br /&gt;                MessageBox.Show(e.Error.Message);&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue;"&gt;else&lt;/span&gt; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (e.Cancelled)&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: green;"&gt;// Next, handle the case where the user canceled &lt;/span&gt;&lt;br /&gt;                &lt;span style="color: green;"&gt;// the operation.&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: green;"&gt;// Note that due to a race condition in &lt;/span&gt;&lt;br /&gt;                &lt;span style="color: green;"&gt;// the DoWork event handler, the Cancelled&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: green;"&gt;// flag may not have been set, even though&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: green;"&gt;// CancelAsync was called.&lt;/span&gt;&lt;br /&gt;                resultLabel.Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Canceled"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;span style="color: green;"&gt;// Finally, handle the case where the operation &lt;/span&gt;&lt;br /&gt;                &lt;span style="color: green;"&gt;// succeeded.&lt;/span&gt;&lt;br /&gt;                resultLabel.Text = e.Result.ToString();&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Enable the UpDown control.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.Enabled = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Enable the Start button.&lt;/span&gt;&lt;br /&gt;            startAsyncButton.Enabled = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Disable the Cancel button.&lt;/span&gt;&lt;br /&gt;            cancelAsyncButton.Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;// This event handler updates the progress bar.&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; backgroundWorker1_ProgressChanged(object sender,&lt;br /&gt;            ProgressChangedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.progressBar1.Value = e.ProgressPercentage;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt;        &lt;span style="color: green;"&gt;// This is the method that does the actual work. For this&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;// example, it computes a Fibonacci number and&lt;/span&gt;&lt;br /&gt;        &lt;span style="color: green;"&gt;// reports progress as it does its work.&lt;/span&gt;&lt;br /&gt;        long ComputeFibonacci(&lt;span style="color: blue;"&gt;int&lt;/span&gt; n, BackgroundWorker worker, DoWorkEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: green;"&gt;// The parameter n must be &amp;gt;= 0 and &amp;lt;= 91.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// Fib(n), with n &amp;gt; 91, overflows a long.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;if&lt;/span&gt; ((n &amp;lt; 0) || (n &amp;gt; 91))&lt;br /&gt;            {&lt;br /&gt;                throw &lt;span style="color: blue;"&gt;new&lt;/span&gt; ArgumentException(&lt;br /&gt;                    &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"value must be &amp;gt;= 0 and &amp;lt;= 91"&lt;/span&gt;&lt;/span&gt;, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"n"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            long result = 0;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: green;"&gt;// Abort the operation if the user has canceled.&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// Note that a call to CancelAsync may have set &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// CancellationPending to true just after the&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// last invocation of this method exits, so this &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// code will not have the opportunity to set the &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// DoWorkEventArgs.Cancel flag to true. This means&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// that RunWorkerCompletedEventArgs.Cancelled will&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// not be set to true in your RunWorkerCompleted&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// event handler. This is a race condition.&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (worker.CancellationPending)&lt;br /&gt;            {   &lt;br /&gt;                e.Cancel = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt;            }&lt;br /&gt;            &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;br /&gt;            {   &lt;br /&gt;                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (n &amp;lt; 2)&lt;br /&gt;                {   &lt;br /&gt;                    result = 1;&lt;br /&gt;                }&lt;br /&gt;                &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;br /&gt;                {   &lt;br /&gt;                    result = ComputeFibonacci(n - 1, worker, e) + &lt;br /&gt;                             ComputeFibonacci(n - 2, worker, e);&lt;br /&gt;                }&lt;br /&gt; &lt;br /&gt;                &lt;span style="color: green;"&gt;// Report progress as a percentage of the total task.&lt;/span&gt;&lt;br /&gt;                &lt;span style="color: blue;"&gt;int&lt;/span&gt; percentComplete = &lt;br /&gt;                    (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)((&lt;span style="color: blue;"&gt;float&lt;/span&gt;)n / (&lt;span style="color: blue;"&gt;float&lt;/span&gt;)numberToCompute * 100);&lt;br /&gt;                &lt;span style="color: blue;"&gt;if&lt;/span&gt; (percentComplete &amp;gt; highestPercentageReached)&lt;br /&gt;                {&lt;br /&gt;                    highestPercentageReached = percentComplete;&lt;br /&gt;                    worker.ReportProgress(percentComplete);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;            &lt;span style="color: blue;"&gt;return&lt;/span&gt; result;&lt;br /&gt;        }&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;        #region Windows Form Designer generated code&lt;br /&gt;        &lt;br /&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; InitializeComponent()&lt;br /&gt;        {&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1 = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Windows.Forms.NumericUpDown();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Windows.Forms.Button();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Windows.Forms.Button();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Windows.Forms.Label();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.progressBar1 = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Windows.Forms.ProgressBar();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.backgroundWorker1 = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.ComponentModel.BackgroundWorker();&lt;br /&gt;            ((System.ComponentModel.ISupportInitialize)(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1)).BeginInit();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.SuspendLayout();&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// numericUpDown1&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.Location = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Point(16, 16);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.Maximum = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Decimal(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;[] {&lt;br /&gt;            91,&lt;br /&gt;            0,&lt;br /&gt;            0,&lt;br /&gt;            0});&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.Minimum = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Decimal(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;[] {&lt;br /&gt;            1,&lt;br /&gt;            0,&lt;br /&gt;            0,&lt;br /&gt;            0});&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"numericUpDown1"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.Size = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Size(80, 20);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.TabIndex = 0;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1.Value = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Decimal(&lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;[] {&lt;br /&gt;            1,&lt;br /&gt;            0,&lt;br /&gt;            0,&lt;br /&gt;            0});&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// startAsyncButton&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton.Location = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Point(16, 72);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton.Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"startAsyncButton"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton.Size = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Size(120, 23);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton.TabIndex = 1;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton.Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Start Async"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton.Click += &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.EventHandler(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton_Click);&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// cancelAsyncButton&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton.Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton.Location = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Point(153, 72);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton.Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"cancelAsyncButton"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton.Size = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Size(119, 23);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton.TabIndex = 2;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton.Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Cancel Async"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton.Click += &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.EventHandler(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton_Click);&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// resultLabel&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel.Location = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Point(112, 16);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel.Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"resultLabel"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel.Size = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Size(160, 23);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel.TabIndex = 3;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel.Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"(no result)"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// progressBar1&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.progressBar1.Location = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Point(18, 48);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.progressBar1.Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"progressBar1"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.progressBar1.Size = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Size(256, 8);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.progressBar1.Step = 2;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.progressBar1.TabIndex = 4;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// backgroundWorker1&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.backgroundWorker1.WorkerReportsProgress = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.backgroundWorker1.WorkerSupportsCancellation = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// FibonacciForm&lt;/span&gt;&lt;br /&gt;            &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.ClientSize = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Drawing.Size(292, 118);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.progressBar1);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.resultLabel);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.cancelAsyncButton);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.startAsyncButton);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Controls.Add(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1);&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"FibonacciForm"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Fibonacci Calculator"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;            ((System.ComponentModel.ISupportInitialize)(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.numericUpDown1)).EndInit();&lt;br /&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.ResumeLayout(&lt;span style="color: blue;"&gt;false&lt;/span&gt;);&lt;br /&gt; &lt;br /&gt;        }&lt;br /&gt;        #endregion&lt;br /&gt; &lt;br /&gt;        [STAThread]&lt;br /&gt;        &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main()&lt;br /&gt;        {&lt;br /&gt;            Application.Run(&lt;span style="color: blue;"&gt;new&lt;/span&gt; FibonacciForm());&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl58_ctl00_ctl02_ManagedCPlusPlus"&gt;&lt;br /&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;Visual C++&lt;/div&gt;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl58_ctl00_ctl02_code" space="preserve"&gt;#&lt;span style="color: blue;"&gt;using&lt;/span&gt; &amp;lt;System.Drawing.dll&amp;gt;&lt;br /&gt;#&lt;span style="color: blue;"&gt;using&lt;/span&gt; &amp;lt;System.dll&amp;gt;&lt;br /&gt;#&lt;span style="color: blue;"&gt;using&lt;/span&gt; &amp;lt;System.Windows.Forms.dll&amp;gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: blue;"&gt;namespace&lt;/span&gt; System;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: blue;"&gt;namespace&lt;/span&gt; System::Collections;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: blue;"&gt;namespace&lt;/span&gt; System::ComponentModel;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: blue;"&gt;namespace&lt;/span&gt; System::Drawing;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: blue;"&gt;namespace&lt;/span&gt; System::Threading;&lt;br /&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; &lt;span style="color: blue;"&gt;namespace&lt;/span&gt; System::Windows::Forms;&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; ref &lt;span style="color: blue;"&gt;class&lt;/span&gt; FibonacciForm: &lt;span style="color: blue;"&gt;public&lt;/span&gt; System::Windows::Forms::Form&lt;br /&gt;{&lt;br /&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;:&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: blue;"&gt;int&lt;/span&gt; numberToCompute;&lt;br /&gt;   &lt;span style="color: blue;"&gt;int&lt;/span&gt; highestPercentageReached;&lt;br /&gt; &lt;br /&gt;   System::Windows::Forms::NumericUpDown^ numericUpDown1;&lt;br /&gt;   System::Windows::Forms::Button^ startAsyncButton;&lt;br /&gt;   System::Windows::Forms::Button^ cancelAsyncButton;&lt;br /&gt;   System::Windows::Forms::ProgressBar^ progressBar1;&lt;br /&gt;   System::Windows::Forms::Label ^ resultLabel;&lt;br /&gt;   System::ComponentModel::BackgroundWorker^ backgroundWorker1;&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt;:&lt;br /&gt;   FibonacciForm()&lt;br /&gt;   {&lt;br /&gt;      InitializeComponent();&lt;br /&gt;      numberToCompute = highestPercentageReached = 0;&lt;br /&gt;      InitializeBackgoundWorker();&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;private&lt;/span&gt;:&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: green;"&gt;// Set up the BackgroundWorker object by &lt;/span&gt;&lt;br /&gt;   &lt;span style="color: green;"&gt;// attaching event handlers. &lt;/span&gt;&lt;br /&gt;   &lt;span style="color: blue;"&gt;void&lt;/span&gt; InitializeBackgoundWorker()&lt;br /&gt;   {&lt;br /&gt;      backgroundWorker1-&amp;gt;DoWork += gcnew DoWorkEventHandler( &lt;span style="color: blue;"&gt;this&lt;/span&gt;, &amp;amp;FibonacciForm::backgroundWorker1_DoWork );&lt;br /&gt;      backgroundWorker1-&amp;gt;RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler( &lt;span style="color: blue;"&gt;this&lt;/span&gt;, &amp;amp;FibonacciForm::backgroundWorker1_RunWorkerCompleted );&lt;br /&gt;      backgroundWorker1-&amp;gt;ProgressChanged += gcnew ProgressChangedEventHandler( &lt;span style="color: blue;"&gt;this&lt;/span&gt;, &amp;amp;FibonacciForm::backgroundWorker1_ProgressChanged );&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: blue;"&gt;void&lt;/span&gt; startAsyncButton_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )&lt;br /&gt;   {&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Reset the text in the result label.&lt;/span&gt;&lt;br /&gt;      resultLabel-&amp;gt;Text = String::Empty;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Disable the UpDown control until &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// the asynchronous operation is done.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Disable the Start button until &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// the asynchronous operation is done.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton-&amp;gt;Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Enable the Cancel button while &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// the asynchronous operation runs.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton-&amp;gt;Enabled = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Get the value from the UpDown control.&lt;/span&gt;&lt;br /&gt;      numberToCompute = (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)numericUpDown1-&amp;gt;Value;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Reset the variable for percentage tracking.&lt;/span&gt;&lt;br /&gt;      highestPercentageReached = 0;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Start the asynchronous operation.&lt;/span&gt;&lt;br /&gt;      backgroundWorker1-&amp;gt;RunWorkerAsync( numberToCompute );&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: blue;"&gt;void&lt;/span&gt; cancelAsyncButton_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )&lt;br /&gt;   {  &lt;br /&gt;      &lt;span style="color: green;"&gt;// Cancel the asynchronous operation.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;backgroundWorker1-&amp;gt;CancelAsync();&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Disable the Cancel button.&lt;/span&gt;&lt;br /&gt;      cancelAsyncButton-&amp;gt;Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: green;"&gt;// This event handler is where the actual,&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: green;"&gt;// potentially time-consuming work is done.&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: blue;"&gt;void&lt;/span&gt; backgroundWorker1_DoWork( Object^ sender, DoWorkEventArgs^ e )&lt;br /&gt;   {&lt;br /&gt;      &lt;span style="color: green;"&gt;// Get the BackgroundWorker that raised this event.&lt;/span&gt;&lt;br /&gt;      BackgroundWorker^ worker = dynamic_cast&amp;lt;BackgroundWorker^&amp;gt;(sender);&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Assign the result of the computation&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// to the Result property of the DoWorkEventArgs&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// object. This is will be available to the &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// RunWorkerCompleted eventhandler.&lt;/span&gt;&lt;br /&gt;      e-&amp;gt;Result = ComputeFibonacci( safe_cast&amp;lt;Int32&amp;gt;(e-&amp;gt;Argument), worker, e );&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: green;"&gt;// This event handler deals with the results of the&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: green;"&gt;// background operation.&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: blue;"&gt;void&lt;/span&gt; backgroundWorker1_RunWorkerCompleted( Object^ /*sender*/, RunWorkerCompletedEventArgs^ e )&lt;br /&gt;   {&lt;br /&gt;      &lt;span style="color: green;"&gt;// First, handle the case where an exception was thrown.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( e-&amp;gt;Error != nullptr )&lt;br /&gt;      {&lt;br /&gt;         MessageBox::Show( e-&amp;gt;Error-&amp;gt;Message );&lt;br /&gt;      }&lt;br /&gt;      &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( e-&amp;gt;Cancelled )&lt;br /&gt;      {&lt;br /&gt;         &lt;span style="color: green;"&gt;// Next, handle the case where the user cancelled &lt;/span&gt;&lt;br /&gt;         &lt;span style="color: green;"&gt;// the operation.&lt;/span&gt;&lt;br /&gt;         &lt;span style="color: green;"&gt;// Note that due to a race condition in &lt;/span&gt;&lt;br /&gt;         &lt;span style="color: green;"&gt;// the DoWork event handler, the Cancelled&lt;/span&gt;&lt;br /&gt;         &lt;span style="color: green;"&gt;// flag may not have been set, even though&lt;/span&gt;&lt;br /&gt;         &lt;span style="color: green;"&gt;// CancelAsync was called.&lt;/span&gt;&lt;br /&gt;         resultLabel-&amp;gt;Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Cancelled"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      }&lt;br /&gt;      &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;br /&gt;      {&lt;br /&gt;         &lt;span style="color: green;"&gt;// Finally, handle the case where the operation &lt;/span&gt;&lt;br /&gt;         &lt;span style="color: green;"&gt;// succeeded.&lt;/span&gt;&lt;br /&gt;         resultLabel-&amp;gt;Text = e-&amp;gt;Result-&amp;gt;ToString();&lt;br /&gt;      }&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Enable the UpDown control.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;Enabled = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Enable the Start button.&lt;/span&gt;&lt;br /&gt;      startAsyncButton-&amp;gt;Enabled = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Disable the Cancel button.&lt;/span&gt;&lt;br /&gt;      cancelAsyncButton-&amp;gt;Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: green;"&gt;// This event handler updates the progress bar.&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: blue;"&gt;void&lt;/span&gt; backgroundWorker1_ProgressChanged( Object^ /*sender*/, ProgressChangedEventArgs^ e )&lt;br /&gt;   {&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;progressBar1-&amp;gt;Value = e-&amp;gt;ProgressPercentage;&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: green;"&gt;// This is the method that does the actual work. For this&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: green;"&gt;// example, it computes a Fibonacci number and&lt;/span&gt;&lt;br /&gt;   &lt;span style="color: green;"&gt;// reports progress as it does its work.&lt;/span&gt;&lt;br /&gt;   long ComputeFibonacci( &lt;span style="color: blue;"&gt;int&lt;/span&gt; n, BackgroundWorker^ worker, DoWorkEventArgs ^ e )&lt;br /&gt;   {&lt;br /&gt;      &lt;span style="color: green;"&gt;// The parameter n must be &amp;gt;= 0 and &amp;lt;= 91.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// Fib(n), with n &amp;gt; 91, overflows a long.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( (n &amp;lt; 0) || (n &amp;gt; 91) )&lt;br /&gt;      {&lt;br /&gt;         throw gcnew ArgumentException( &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"value must be &amp;gt;= 0 and &amp;lt;= 91"&lt;/span&gt;&lt;/span&gt;,&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"n"&lt;/span&gt;&lt;/span&gt; );&lt;br /&gt;      }&lt;br /&gt; &lt;br /&gt;      long result = 0;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// Abort the operation if the user has cancelled.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// Note that a call to CancelAsync may have set &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// CancellationPending to true just after the&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// last invocation of this method exits, so this &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// code will not have the opportunity to set the &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// DoWorkEventArgs.Cancel flag to true. This means&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// that RunWorkerCompletedEventArgs.Cancelled will&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// not be set to true in your RunWorkerCompleted&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// event handler. This is a race condition.&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( worker-&amp;gt;CancellationPending )&lt;br /&gt;      {&lt;br /&gt;         e-&amp;gt;Cancel = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt;      }&lt;br /&gt;      &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;br /&gt;      {&lt;br /&gt;         &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( n &amp;lt; 2 )&lt;br /&gt;         {&lt;br /&gt;            result = 1;&lt;br /&gt;         }&lt;br /&gt;         &lt;span style="color: blue;"&gt;else&lt;/span&gt;&lt;br /&gt;         {&lt;br /&gt;            result = ComputeFibonacci( n - 1, worker, e ) + ComputeFibonacci( n - 2, worker, e );&lt;br /&gt;         }&lt;br /&gt; &lt;br /&gt;         &lt;span style="color: green;"&gt;// Report progress as a percentage of the total task.&lt;/span&gt;&lt;br /&gt;         &lt;span style="color: blue;"&gt;int&lt;/span&gt; percentComplete = (&lt;span style="color: blue;"&gt;int&lt;/span&gt;)((&lt;span style="color: blue;"&gt;float&lt;/span&gt;)n / (&lt;span style="color: blue;"&gt;float&lt;/span&gt;)numberToCompute * 100);&lt;br /&gt;         &lt;span style="color: blue;"&gt;if&lt;/span&gt; ( percentComplete &amp;gt; highestPercentageReached )&lt;br /&gt;         {&lt;br /&gt;            highestPercentageReached = percentComplete;&lt;br /&gt;            worker-&amp;gt;ReportProgress( percentComplete );&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: blue;"&gt;return&lt;/span&gt; result;&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   &lt;span style="color: blue;"&gt;void&lt;/span&gt; InitializeComponent()&lt;br /&gt;   {&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1 = gcnew System::Windows::Forms::NumericUpDown;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton = gcnew System::Windows::Forms::Button;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton = gcnew System::Windows::Forms::Button;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel = gcnew System::Windows::Forms::Label;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;progressBar1 = gcnew System::Windows::Forms::ProgressBar;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;backgroundWorker1 = gcnew System::ComponentModel::BackgroundWorker;&lt;br /&gt;      (dynamic_cast&amp;lt;System::ComponentModel::ISupportInitialize^&amp;gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1))-&amp;gt;BeginInit();&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;SuspendLayout();&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// numericUpDown1&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;Location = System::Drawing::Point( 16, 16 );&lt;br /&gt;      array&amp;lt;Int32&amp;gt;^temp0 = {91,0,0,0};&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;Maximum = System::Decimal( temp0 );&lt;br /&gt;      array&amp;lt;Int32&amp;gt;^temp1 = {1,0,0,0};&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;Minimum = System::Decimal( temp1 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"numericUpDown1"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;Size = System::Drawing::Size( 80, 20 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;TabIndex = 0;&lt;br /&gt;      array&amp;lt;Int32&amp;gt;^temp2 = {1,0,0,0};&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1-&amp;gt;Value = System::Decimal( temp2 );&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// startAsyncButton&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton-&amp;gt;Location = System::Drawing::Point( 16, 72 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton-&amp;gt;Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"startAsyncButton"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton-&amp;gt;Size = System::Drawing::Size( 120, 23 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton-&amp;gt;TabIndex = 1;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton-&amp;gt;Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Start Async"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton-&amp;gt;Click += gcnew System::EventHandler( &lt;span style="color: blue;"&gt;this&lt;/span&gt;, &amp;amp;FibonacciForm::startAsyncButton_Click );&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// cancelAsyncButton&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton-&amp;gt;Enabled = &lt;span style="color: blue;"&gt;false&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton-&amp;gt;Location = System::Drawing::Point( 153, 72 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton-&amp;gt;Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"cancelAsyncButton"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton-&amp;gt;Size = System::Drawing::Size( 119, 23 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton-&amp;gt;TabIndex = 2;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton-&amp;gt;Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Cancel Async"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton-&amp;gt;Click += gcnew System::EventHandler( &lt;span style="color: blue;"&gt;this&lt;/span&gt;, &amp;amp;FibonacciForm::cancelAsyncButton_Click );&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// resultLabel&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel-&amp;gt;BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel-&amp;gt;Location = System::Drawing::Point( 112, 16 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel-&amp;gt;Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"resultLabel"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel-&amp;gt;Size = System::Drawing::Size( 160, 23 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel-&amp;gt;TabIndex = 3;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel-&amp;gt;Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"(no result)"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel-&amp;gt;TextAlign = System::Drawing::ContentAlignment::MiddleCenter;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// progressBar1&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;progressBar1-&amp;gt;Location = System::Drawing::Point( 18, 48 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;progressBar1-&amp;gt;Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"progressBar1"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;progressBar1-&amp;gt;Size = System::Drawing::Size( 256, 8 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;progressBar1-&amp;gt;Step = 2;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;progressBar1-&amp;gt;TabIndex = 4;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// backgroundWorker1&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;backgroundWorker1-&amp;gt;WorkerReportsProgress = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;backgroundWorker1-&amp;gt;WorkerSupportsCancellation = &lt;span style="color: blue;"&gt;true&lt;/span&gt;;&lt;br /&gt; &lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// FibonacciForm&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: green;"&gt;// &lt;/span&gt;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;ClientSize = System::Drawing::Size( 292, 118 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;Controls-&amp;gt;Add( &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;progressBar1 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;Controls-&amp;gt;Add( &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;resultLabel );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;Controls-&amp;gt;Add( &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;cancelAsyncButton );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;Controls-&amp;gt;Add( &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;startAsyncButton );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;Controls-&amp;gt;Add( &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1 );&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;Name = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"FibonacciForm"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;Text = &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Fibonacci Calculator"&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;      (dynamic_cast&amp;lt;System::ComponentModel::ISupportInitialize^&amp;gt;(&lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;numericUpDown1))-&amp;gt;EndInit();&lt;br /&gt;      &lt;span style="color: blue;"&gt;this&lt;/span&gt;-&amp;gt;ResumeLayout( &lt;span style="color: blue;"&gt;false&lt;/span&gt; );&lt;br /&gt;   }&lt;br /&gt;};&lt;br /&gt; &lt;br /&gt;[STAThread]&lt;br /&gt;&lt;span style="color: blue;"&gt;int&lt;/span&gt; main()&lt;br /&gt;{&lt;br /&gt;   Application::Run( gcnew FibonacciForm );&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-2654057438265508581?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/2654057438265508581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=2654057438265508581' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2654057438265508581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2654057438265508581'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/backgroundworker-class.html' title='BackgroundWorker Class'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-2270863645901151782</id><published>2010-03-03T23:28:00.000-08:00</published><updated>2010-03-03T23:28:11.410-08:00</updated><title type='text'>ASP.NET Forms Authentication Overview</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/7t6b43z4.aspx"&gt;http://msdn.microsoft.com/en-us/library/7t6b43z4.aspx&lt;/a&gt; &lt;br /&gt;Forms authentication lets you authenticate users by using your own code and then maintain an authentication token in a cookie or in the page URL. Forms authentication participates in the ASP.NET page life cycle through the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationmodule.aspx" id="ctl00_MTCS_main_ctl01" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl01',this);"&gt;FormsAuthenticationModule&lt;/a&gt; class. You can access forms authentication information and capabilities through the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.aspx" id="ctl00_MTCS_main_ctl02" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl02',this);"&gt;FormsAuthentication&lt;/a&gt; class.&lt;br /&gt;To use forms authentication, you create a login page that collects credentials from the user and that includes code to authenticate the credentials. Typically you configure the application to redirect requests to the login page when users try to access a protected resource, such as a page that requires authentication. If the user's credentials are valid, you can call methods of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.aspx" id="ctl00_MTCS_main_ctl03" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl03',this);"&gt;FormsAuthentication&lt;/a&gt; class to redirect the request back to the originally requested resource with an appropriate authentication ticket (cookie). If you do not want the redirection, you can just get the forms authentication cookie or set it. On subsequent requests, the user's browser passes the authentication cookie with the request, which then bypasses the login page.&lt;br /&gt;You configure forms authentication by using the &lt;a href="http://msdn.microsoft.com/en-us/library/532aee0e.aspx" id="ctl00_MTCS_main_ctl04" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl04',this);"&gt;authentication&lt;/a&gt; configuration element. In the simplest case, you have a login page. In the configuration file, you specify a URL to redirect unauthenticated requests to the login page. You then define valid credentials, either in the Web.config file or in a separate file. The following example shows a section from a configuration file that specifies a login page and authentication credentials for the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.authenticate.aspx" id="ctl00_MTCS_main_ctl05" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl05',this);"&gt;Authenticate&lt;/a&gt; method. The passwords have been encrypted by using the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.hashpasswordforstoringinconfigfile.aspx" id="ctl00_MTCS_main_ctl06" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl06',this);"&gt;HashPasswordForStoringInConfigFile&lt;/a&gt; method.&lt;span id="ctl00_MTCS_main_ctl07"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl07_"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CopyCodeButton"&gt;&lt;a class="copyCode" href="javascript:CopyCode('ctl00_MTCS_main_ctl07_code');" title="Copy Code"&gt;Copy Code&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl07_code" space="preserve"&gt;&amp;lt;authentication mode="Forms"&amp;gt;&lt;br /&gt;   &amp;lt;forms name="SavingsPlan" loginUrl="/Login.aspx"&amp;gt;&lt;br /&gt;      &amp;lt;credentials passwordFormat="SHA1"&amp;gt;&lt;br /&gt;         &amp;lt;user name="Kim"&lt;br /&gt;               password="07B7F3EE06F278DB966BE960E7CBBD103DF30CA6"/&amp;gt;&lt;br /&gt;         &amp;lt;user name="John"&lt;br /&gt;               password="BA56E5E0366D003E98EA1C7F04ABF8FCB3753889"/&amp;gt;&lt;br /&gt;      &amp;lt;/credentials&amp;gt;&lt;br /&gt;   &amp;lt;/forms&amp;gt;&lt;br /&gt;&amp;lt;/authentication&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;After successful authentication, the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationmodule.aspx" id="ctl00_MTCS_main_ctl08" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl08',this);"&gt;FormsAuthenticationModule&lt;/a&gt; module sets the value of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx" id="ctl00_MTCS_main_ctl09" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl09',this);"&gt;User&lt;/a&gt; property to a reference to the authenticated user. The following code example shows how to programmatically read the identity of the forms-authenticated user.&lt;br /&gt;&lt;span id="ctl00_MTCS_main_ctl10"&gt;&lt;/span&gt;&lt;span id="ctl00_MTCS_main_ctl11"&gt;C#&lt;/span&gt;&lt;img class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; vertical-align: middle;" /&gt;&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl10_VisualBasic"&gt;Visual Basic&lt;br /&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;a class="copyCode" href="javascript:CopyCode('ctl00_MTCS_main_ctl10_code');" title="Copy Code"&gt;Copy Code&lt;/a&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl10_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; authUser2 &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt; = User.Identity.Name&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl11_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;a class="copyCode" href="javascript:CopyCode('ctl00_MTCS_main_ctl11_code');" title="Copy Code"&gt;Copy Code&lt;/a&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl11_code" space="preserve"&gt;String authUser2 = User.Identity.Name;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="CollapseRegionLink"&gt;&amp;nbsp;Forms Authentication, ASP.NET Membership, and Login Controls&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;&lt;a href="" id="sectionToggle0"&gt;&lt;/a&gt;&lt;br /&gt;A convenient way to work with forms authentication is to use ASP.NET membership and ASP.NET login controls. ASP.NET membership lets you store and manage user information and includes methods to authenticate users. ASP.NET login controls work with ASP.NET membership. They encapsulate the logic to prompt users for credentials, validate users, recover or replace passwords, and so on. In effect, ASP.NET membership and ASP.NET login controls provide a layer of abstraction over forms authentication. These features replace most or all the work that you would ordinarily have to do to use forms authentication. For more information, see &lt;a href="http://msdn.microsoft.com/en-us/library/tw292whz.aspx" id="ctl00_MTCS_main_ctl32_ctl00_ctl00" onclick="javascript:Track('ctl00_MTCS_main_ctl32_ctl00_contenthere|ctl00_MTCS_main_ctl32_ctl00_ctl00',this);"&gt;Managing Users by Using Membership&lt;/a&gt; and the &lt;a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" id="ctl00_MTCS_main_ctl32_ctl00_ctl01" onclick="javascript:Track('ctl00_MTCS_main_ctl32_ctl00_contenthere|ctl00_MTCS_main_ctl32_ctl00_ctl01',this);"&gt;ASP.NET Login Controls Overview&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="CollapseRegionLink"&gt;&lt;br /&gt;&lt;img class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; vertical-align: middle;" /&gt;&amp;nbsp;Forms Authentication and the Authentication Service&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;&lt;a href="" id="sectionToggle1"&gt;&lt;/a&gt;&lt;br /&gt;You can also access forms authentication as a Windows Communication Framework (WCF) service by using the ASP.NET authentication service. The authentication service enables you to use forms authentication from any application that can send and consume messages in SOAP format. The authentication service accepts user credentials and returns a forms authentication cookie.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-2270863645901151782?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/2270863645901151782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=2270863645901151782' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2270863645901151782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/2270863645901151782'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/aspnet-forms-authentication-overview.html' title='ASP.NET Forms Authentication Overview'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1735900030594286818</id><published>2010-03-03T23:23:00.001-08:00</published><updated>2010-03-03T23:23:59.841-08:00</updated><title type='text'>ASP.NET Authentication</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/eeyk640h.aspx"&gt;http://msdn.microsoft.com/en-us/library/eeyk640h.aspx&lt;/a&gt; &lt;br /&gt;Authentication is the process of obtaining identification credentials such as name and password from a user and validating those credentials against some authority. If the credentials are valid, the entity that submitted the credentials is considered an authenticated identity. Once an identity has been authenticated, the authorization process determines whether that identity has access to a given resource.&lt;br /&gt;ASP.NET implements authentication through authentication providers, the code modules that contain the code necessary to authenticate the requestor's credentials. The topics in this section describe the authentication providers built into ASP.NET.&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="CollapseRegionLink"&gt;&lt;br /&gt;&lt;img class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; vertical-align: middle;" /&gt;&lt;br /&gt;&amp;nbsp;In This Section&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;&lt;a href="" id="inThisSectionToggle"&gt;&lt;/a&gt;&lt;br /&gt;&lt;div class="caption"&gt;&lt;/div&gt;&lt;div class="tableSection"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Term&lt;/th&gt;&lt;th&gt;Definition&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/907hb5w9.aspx" id="ctl00_MTCS_main_ctl10_ctl00_ctl00" onclick="javascript:Track('ctl00_MTCS_main_ctl10_ctl00_contenthere|ctl00_MTCS_main_ctl10_ctl00_ctl00',this);"&gt;Windows Authentication Provider&lt;/a&gt; &lt;/td&gt;&lt;td&gt;Provides information on how to use Windows authentication in conjunction with Microsoft Internet Information Services (IIS) authentication to secure ASP.NET applications.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/9wff0kyh.aspx" id="ctl00_MTCS_main_ctl10_ctl00_ctl01" onclick="javascript:Track('ctl00_MTCS_main_ctl10_ctl00_contenthere|ctl00_MTCS_main_ctl10_ctl00_ctl01',this);"&gt;Forms Authentication Provider&lt;/a&gt; &lt;/td&gt;&lt;td&gt;Provides information on how to create an application-specific login form and perform authentication using your own code. A convenient way to work with forms authentication is to use ASP.NET membership and ASP.NET login controls, which together provide a way to collect user credentials, authenticate them, and manage them, using little or no code. For more information, see &lt;a href="http://msdn.microsoft.com/en-us/library/tw292whz.aspx" id="ctl00_MTCS_main_ctl10_ctl00_ctl02" onclick="javascript:Track('ctl00_MTCS_main_ctl10_ctl00_contenthere|ctl00_MTCS_main_ctl10_ctl00_ctl02',this);"&gt;Managing Users by Using Membership&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" id="ctl00_MTCS_main_ctl10_ctl00_ctl03" onclick="javascript:Track('ctl00_MTCS_main_ctl10_ctl00_contenthere|ctl00_MTCS_main_ctl10_ctl00_ctl03',this);"&gt;ASP.NET Login Controls Overview&lt;/a&gt;.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;You might also consider using Windows Live ID for user authentication. For information about how to use Windows Live ID to authenticate users for you website&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1735900030594286818?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1735900030594286818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1735900030594286818' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1735900030594286818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1735900030594286818'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/aspnet-authentication.html' title='ASP.NET Authentication'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-6059416778230577184</id><published>2010-03-03T22:57:00.000-08:00</published><updated>2010-03-03T23:11:13.555-08:00</updated><title type='text'>Exception Handling Application Block</title><content type='html'>This topic includes a series of brief sections that provide information to help you decide whether the Exception Handling Application Block is suitable for your requirements. This topic includes the following sections:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=1391330880345771186#intro_commonscenarios"&gt;Common Scenarios&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=1391330880345771186#intro_handlers"&gt;Using Exception Handlers&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=1391330880345771186#intro_polocoes"&gt;Using Exception Policies&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=1391330880345771186#intro_examplecode"&gt;Example Application Code&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.blogger.com/post-create.g?blogID=1391330880345771186#intro_whentouse"&gt;When to Use the Exception Handling Application Block&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;In addition to this introductory material, the documentation contains the following topics:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511737.aspx" id="ctl00_MTCS_main_ctl01" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl01',this);"&gt;Developing Applications Using the Exception Handling Application Block&lt;/a&gt;. This topic explains how to configure the Exception Handling Application Block, how to add the block to your applications, how to determine appropriate exception handling policies, how to specify different handling actions, and how to send an exception to the Exception Handling Block. &lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511533.aspx" id="ctl00_MTCS_main_ctl02" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl02',this);"&gt;Key Scenarios&lt;/a&gt;. This topic shows different ways to use the Exception Handling Application Block in your own applications.&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511836.aspx" id="ctl00_MTCS_main_ctl03" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl03',this);"&gt;Design of the Exception Handling Application Block&lt;/a&gt;. This topic explains the decisions that went into designing the application block and the rationale behind those decisions.&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511781.aspx" id="ctl00_MTCS_main_ctl04" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl04',this);"&gt;Extending and Modifying the Exception Handling Application Block&lt;/a&gt;. This topic explains how to extend the application block by adding custom handlers and formatters. It also gives some advice about how to modify the source code.&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511623.aspx" id="ctl00_MTCS_main_ctl05" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl05',this);"&gt;Deployment and Operations&lt;/a&gt;. This topic explains how to deploy and update the application block assemblies.&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511657.aspx" id="ctl00_MTCS_main_ctl06" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl06',this);"&gt;Exception Handling QuickStarts&lt;/a&gt;. This topic explains how to install and configure the QuickStart applications and contains a series of walkthroughs that demonstrate how to incorporate common exception handling operations in an application.&lt;/li&gt;&lt;/ul&gt;For details of the system requirements for the Exception Handling Application Block, see &lt;a href="http://msdn.microsoft.com/en-us/library/cc511797.aspx" id="ctl00_MTCS_main_ctl07" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl07',this);"&gt;System Requirements&lt;/a&gt;. For details of the dependencies for the Exception Handling Application Block, see &lt;a href="http://msdn.microsoft.com/en-us/library/cc511715.aspx" id="ctl00_MTCS_main_ctl08" onclick="javascript:Track('ctl00_MTCS_main_ctl00|ctl00_MTCS_main_ctl08',this);"&gt;Application Block Dependencies&lt;/a&gt;. &lt;br /&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="CollapseRegionLink"&gt;Common Scenarios&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;The Exception Handling Application Block is designed to address the most common tasks developers face when they write applications that use exception handling. These tasks are arranged according to scenarios. Each scenario gives an example of a real-world situation, discusses the exception handling functions the situation requires, and shows the code that accomplishes the task.&lt;br /&gt;The goal of arranging these tasks according to scenarios is to give the code some context. Instead of displaying an isolated group of methods, with no sense of where they can best be used, scenarios provide a setting for the code and describe situations that are familiar to many developers whose applications must handle exceptions.&lt;br /&gt;The scenarios are the following:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511676.aspx" id="ctl00_MTCS_main_ctl42_ctl00_ctl00" onclick="javascript:Track('ctl00_MTCS_main_ctl42_ctl00_contenthere|ctl00_MTCS_main_ctl42_ctl00_ctl00',this);"&gt;Logging an Exception&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511845.aspx" id="ctl00_MTCS_main_ctl42_ctl00_ctl01" onclick="javascript:Track('ctl00_MTCS_main_ctl42_ctl00_contenthere|ctl00_MTCS_main_ctl42_ctl00_ctl01',this);"&gt;Wrapping an Exception&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511905.aspx" id="ctl00_MTCS_main_ctl42_ctl00_ctl02" onclick="javascript:Track('ctl00_MTCS_main_ctl42_ctl00_contenthere|ctl00_MTCS_main_ctl42_ctl00_ctl02',this);"&gt;Replacing an Exception&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511782.aspx" id="ctl00_MTCS_main_ctl42_ctl00_ctl03" onclick="javascript:Track('ctl00_MTCS_main_ctl42_ctl00_contenthere|ctl00_MTCS_main_ctl42_ctl00_ctl03',this);"&gt;Propagating an Exception&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511834.aspx" id="ctl00_MTCS_main_ctl42_ctl00_ctl04" onclick="javascript:Track('ctl00_MTCS_main_ctl42_ctl00_contenthere|ctl00_MTCS_main_ctl42_ctl00_ctl04',this);"&gt;Displaying User-Friendly Messages&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511762.aspx" id="ctl00_MTCS_main_ctl42_ctl00_ctl05" onclick="javascript:Track('ctl00_MTCS_main_ctl42_ctl00_contenthere|ctl00_MTCS_main_ctl42_ctl00_ctl05',this);"&gt;Notifying the User&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511532.aspx" id="ctl00_MTCS_main_ctl42_ctl00_ctl06" onclick="javascript:Track('ctl00_MTCS_main_ctl42_ctl00_contenthere|ctl00_MTCS_main_ctl42_ctl00_ctl06',this);"&gt;Assisting Support Staff&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc511695.aspx" id="ctl00_MTCS_main_ctl42_ctl00_ctl07" onclick="javascript:Track('ctl00_MTCS_main_ctl42_ctl00_contenthere|ctl00_MTCS_main_ctl42_ctl00_ctl07',this);"&gt;Shielding Exceptions at WCF Service Boundaries&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="CollapseRegionLink"&gt;Using Exception Handlers&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;&lt;br /&gt;The Exception Handling Application Block is designed to support the typical code contained in &lt;strong&gt;catch&lt;/strong&gt; statements in application components. Instead of repeating this code (such as logging exception information) throughout identical catch blocks in an application component, the application block allows developers to encapsulate this logic as reusable exception handlers. Exception handlers are .NET classes that encapsulate exception handling logic and implement the Exception Handling Application Block interface named &lt;strong&gt;IExceptionHandler&lt;/strong&gt;. The Exception Handling Application Block includes four exception handlers:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Wrap handler&lt;/strong&gt;. This exception handler wraps one exception around another.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Replace handler&lt;/strong&gt;. This exception handler replaces one exception with another.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Logging handler&lt;/strong&gt;. This exception handler formats exception information, such as the message and the stack trace. Then the logging handler passes this information to the Enterprise Library Logging Application Block so that it can be published.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Fault Contract Exception Handler&lt;/strong&gt;. This exception handler is designed for use at Windows Communication Foundation (WCF) service boundaries, and generates a new Fault Contract from the exception. &lt;/li&gt;&lt;/ul&gt;Users can extend the Exception Handling Application Block by implementing their own handlers. The Enterprise Library configuration tools provide the ability to configure the Exception Handling Application Block to use custom handlers. Developers do not have to modify the application block source code or rebuild the application block.&lt;/div&gt;&lt;/div&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="CollapseRegionLink"&gt;Using Exception Policies&lt;/div&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;The Exception Handling Application Block lets you associate exception types with named policies. You do this by using the configuration tools. Policies specify the exception handlers that execute when the application block processes a particular exception type. You can chain these handlers together so that a series of them execute when the associated exception type is handled. The following are some examples of named policies and descriptions of what they might provide:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Base policy&lt;/strong&gt;. This policy logs the exception and rethrows the original exception.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Secure policy&lt;/strong&gt;. This policy logs the exception, replaces the original exception with a custom exception, and throws the new exception.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Expressive policy&lt;/strong&gt;. This policy wraps the original exception inside another exception and throws the new exception.&lt;/li&gt;&lt;/ul&gt;Example Application Code&lt;/div&gt;&lt;/div&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;The following code shows how to execute the policy named "Data Access Policy" when an exception occurs.&lt;br /&gt;&lt;span id="ctl00_MTCS_main_ctl45_ctl00_ctl00"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl45_ctl00_ctl00_CSharp"&gt;&lt;br /&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl45_ctl00_ctl00_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;span style="color: green;"&gt;// Run code.&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: blue;"&gt;catch&lt;/span&gt;(Exception ex)&lt;br /&gt;{&lt;br /&gt;  &lt;span style="color: blue;"&gt;bool&lt;/span&gt; rethrow = ExceptionPolicy.HandleException(ex, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;" Data Access Policy"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;  &lt;span style="color: blue;"&gt;if&lt;/span&gt; (rethrow)&lt;br /&gt;    throw;&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;                  &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;span id="ctl00_MTCS_main_ctl45_ctl00_ctl01"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl45_ctl00_ctl01_VisualBasicUsage"&gt;&lt;br /&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;Visual Basic&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl45_ctl00_ctl01_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: green;"&gt;' Run code.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;Catch&lt;/span&gt; ex &lt;span style="color: blue;"&gt;As&lt;/span&gt; Exception&lt;br /&gt;  &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; rethrow &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Boolean&lt;/span&gt; = ExceptionPolicy.HandleException(ex, &lt;span style="color: maroon;"&gt;" Data Access Policy"&lt;/span&gt;)&lt;br /&gt;  &lt;span style="color: blue;"&gt;If&lt;/span&gt; (rethrow) &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue;"&gt;Throw&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;                  &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="alert"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;&lt;br /&gt;&lt;img alt="Cc511859.note(en-us,MSDN.10).gif" src="http://i.msdn.microsoft.com/Cc511859.note(en-us,MSDN.10).gif" /&gt;Note:&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;If you use the Unity Integration approach to create instances of objects from the Exception Handling Application Block, you must use the non-static faÃ§ade named &lt;strong&gt;ExceptionManager&lt;/strong&gt;. This class exposes the same API as the &lt;strong&gt;ExceptionPolicy&lt;/strong&gt; class static faÃ§ade. For more information about using the Unity Application Block to create and inject instances of Enterprise Library objects, see &lt;a href="http://msdn.microsoft.com/en-us/library/cc511545.aspx" id="ctl00_MTCS_main_ctl45_ctl00_ctl03" onclick="javascript:Track('ctl00_MTCS_main_ctl45_ctl00_contenthere|ctl00_MTCS_main_ctl45_ctl00_ctl03',this);"&gt;Creating Objects Using the Unity Application Block&lt;/a&gt;.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;When to Use the Exception Handling Application Block&lt;/div&gt;&lt;/div&gt;&lt;div class="MTPS_CollapsibleRegion"&gt;&lt;div class="MTPS_CollapsibleSection" style="display: block;"&gt;&lt;br /&gt;For information about how to develop exception management strategies, see the &lt;a href="http://msdn.microsoft.com/en-us/library/ms229014(VS.80).aspx" id="ctl00_MTCS_main_ctl46_ctl00_ctl00" onclick="javascript:Track('ctl00_MTCS_main_ctl46_ctl00_contenthere|ctl00_MTCS_main_ctl46_ctl00_ctl00',this);"&gt;&lt;em&gt;Design Guidelines for Exceptions&lt;/em&gt;&lt;/a&gt;. Although it does not specifically discuss the Exception Handling Application Block, it can help you to define a clear, consistent approach to handling exceptions. Use the Exception Management Application Block to help implement your strategy.&lt;br /&gt;The Exception Handling Application Block is best used in situations that require uniform and flexible procedures for handling exceptions. For example, you might want consistent exception handling procedures for all components in a particular tier of an application's architecture. In addition, because of changing security or other operational issues, you might want the ability to change policies as needed, without requiring changes to the application source code. The Exception Handling Application Block, in conjunction with the Enterprise Library configuration tools, lets you accomplish both tasks.&lt;br /&gt;For example, you could use the configuration tools to define a policy that uses handlers to replace exceptions that contain sensitive information with versions that do not include that information. The application block then implements this policy across the components that contain code that specifies this policy should be used.&lt;br /&gt;The Exception Handling Application Block is not limited to cross-tier applications. It can also be used within a particular application. For example, you can define policies that log exception information or display exception information to the user.&lt;br /&gt;In either case, policies are configured without changing the application's code. This makes them easy to maintain or change when new situations occur. Note that, in all cases, you should use the application block to perform only those tasks that are specific to exception handling and that do not intersect with the application's business logic. For example, you can remove the handlers that log an exception or wrap one exception in another without affecting such basic capabilities as updating a customer database.&lt;br /&gt;Figure 1 illustrates examples of cross-layer and single-application component exception handling.&lt;br /&gt;&lt;img alt="Cc511859.9454bca3-fe44-4e18-808b-1373855c65c0(en-us,MSDN.10).png" src="http://i.msdn.microsoft.com/Cc511859.9454bca3-fe44-4e18-808b-1373855c65c0(en-us,MSDN.10).png" /&gt;&lt;br /&gt;&lt;strong&gt;Figure 1&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Examples of exception handling policies&lt;/em&gt;&lt;br /&gt;In this example, exceptions that occur in the data access layer are logged and then wrapped inside another exception that provides more meaningful information to the calling layer. Within the business component layer, the exceptions are logged before they are propagated. Any exceptions that occur in the business component layer and that contain sensitive information are replaced with exceptions that no longer contain this information. These are sent to the user interface (UI) layer and displayed to the user.&lt;br /&gt;Without the Exception Handling Application Block, typical exception handling code for a data access component might look like the following example. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="alert"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;&lt;br /&gt;&lt;img alt="Cc511859.note(en-us,MSDN.10).gif" src="http://i.msdn.microsoft.com/Cc511859.note(en-us,MSDN.10).gif" /&gt;Note:&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;The code does not include implementations of the custom &lt;strong&gt;DataAccessException&lt;/strong&gt; exception type, or the &lt;strong&gt;RunQuery&lt;/strong&gt;,&lt;strong&gt; FormatException&lt;/strong&gt;, and the &lt;strong&gt;Logging.Log&lt;/strong&gt; methods. These methods represent typical ways to retrieve a &lt;strong&gt;DataSet&lt;/strong&gt; and to log information.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;C#&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl46_ctl00_ctl03_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl46_ctl00_ctl03_code" space="preserve"&gt;DataSet customersDataSet;&lt;br /&gt;&lt;span style="color: blue;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;  customersDataSet = RunQuery(&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"GetAllCustomers"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: blue;"&gt;catch&lt;/span&gt;(Exception ex)&lt;br /&gt;{&lt;br /&gt;  &lt;span style="color: blue;"&gt;string&lt;/span&gt; formattedInfo = FormatException(ex);&lt;br /&gt;  Logging.Log(formattedInfo);&lt;br /&gt;  throw &lt;span style="color: blue;"&gt;new&lt;/span&gt; DataAccessException(&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Database access failure for query GetAllCustomers"&lt;/span&gt;&lt;/span&gt;, e);&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;                  &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Visual Basic&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl46_ctl00_ctl04_VisualBasicUsage"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl46_ctl00_ctl04_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; customersDataSet &lt;span style="color: blue;"&gt;As&lt;/span&gt; DataSet&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;br /&gt;  customerDataSet = RunQuery(&lt;span style="color: maroon;"&gt;"GetAllCustomers"&lt;/span&gt;)&lt;br /&gt;&lt;span style="color: blue;"&gt;Catch&lt;/span&gt; ex &lt;span style="color: blue;"&gt;As&lt;/span&gt; Exception&lt;br /&gt;  &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; formattedInfo &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt; = FormatException(ex)&lt;br /&gt;  Logger.Log(formattedInfo)&lt;br /&gt;  &lt;span style="color: blue;"&gt;Throw&lt;/span&gt; &lt;span style="color: blue;"&gt;New&lt;/span&gt; DataAccessException(&lt;span style="color: maroon;"&gt;"Database access failure for query GetAllCustomers"&lt;/span&gt;, e)&lt;br /&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;                  &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Code similar to this would be repeated in all the routines that perform different data access queries. To change the behavior of the exception handling code, you must update each routine that contained this code. &lt;br /&gt;On the other hand, with the Exception Handling Application Block, the same application would have the following code.&lt;br /&gt;&lt;br /&gt;&lt;div class="alert"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;&lt;img alt="Cc511859.note(en-us,MSDN.10).gif" src="http://i.msdn.microsoft.com/Cc511859.note(en-us,MSDN.10).gif" /&gt;Note:&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;The code does not include an implementation of the &lt;strong&gt;RunQuery&lt;/strong&gt; method. This method represents a typical way to retrieve a &lt;strong&gt;DataSet&lt;/strong&gt;. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;C#&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl46_ctl00_ctl06_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;Copy Code&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl46_ctl00_ctl06_code" space="preserve"&gt;DataSet customersDataSet;&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;try&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;  customersDataSet = RunQuery(&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"GetAllCustomers"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: blue;"&gt;catch&lt;/span&gt;(Exception ex)&lt;br /&gt;{&lt;br /&gt;  &lt;span style="color: blue;"&gt;bool&lt;/span&gt; rethrow = ExceptionPolicy.HandleException(ex, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Data Access Policy"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;  &lt;span style="color: blue;"&gt;if&lt;/span&gt; (rethrow)&lt;br /&gt;    throw;&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;                  &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;Visual Basic&lt;br /&gt;&lt;div class="libCScode" id="ctl00_MTCS_main_ctl46_ctl00_ctl07_VisualBasicUsage"&gt;&lt;div class="CodeSnippetTitleBar"&gt;Copy Code&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div dir="ltr" style="background-color: #dddddd;"&gt;&lt;pre class="libCScode" id="ctl00_MTCS_main_ctl46_ctl00_ctl07_code" space="preserve"&gt;&lt;span style="color: blue;"&gt;Dim&lt;/span&gt; customersDataSet &lt;span style="color: blue;"&gt;As&lt;/span&gt; DataSet&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;br /&gt;  customerDataSet = RunQuery(&lt;span style="color: maroon;"&gt;"GetAllCustomers"&lt;/span&gt;)&lt;br /&gt;&lt;span style="color: blue;"&gt;Catch&lt;/span&gt; ex &lt;span style="color: blue;"&gt;As&lt;/span&gt; Exception&lt;br /&gt;  &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; rethrow &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Boolean&lt;/span&gt; = ExceptionPolicy.HandleException(ex, &lt;span style="color: maroon;"&gt;"Data Access  Policy"&lt;/span&gt;)&lt;br /&gt;  &lt;span style="color: blue;"&gt;If&lt;/span&gt; (rethrow) &lt;span style="color: blue;"&gt;Then&lt;/span&gt;&lt;br /&gt;    &lt;span style="color: blue;"&gt;Throw&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Try&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;                  &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;The behavior of the exception handling code is determined by an exception handling policy named Data Access Policy. The application would have configuration settings for the Data Access Policy to indicate that exceptions of type &lt;strong&gt;System.Exception&lt;/strong&gt; are passed to the Logging Exception Handler for the Exception Handling Application Block. To change the behavior of the exception handling code, you change configuration information only; you do not have to update application source code.&lt;br /&gt;The Exception Handling Application Block is a complement to exception handling recovery code; it is not a replacement for it. If exceptions occur because of truly unusual circumstances, it can be impossible for an application to recover gracefully and finish the unit of work it has started. However, it is sometimes possible to recover. An example is an exception that occurs because a file is locked. The recovery code might direct the application to retry the file after waiting for some period of time. In such cases, exception handling recovery code should be implemented within the application code; it should not be implemented as a handler used by the Exception Handling Application Block. This is because it requires access to local variables, parameters, and other contextual data. This data is out of scope and inaccessible to handlers run by the Exception Handling Application Block.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-6059416778230577184?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/6059416778230577184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=6059416778230577184' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6059416778230577184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6059416778230577184'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/this-topic-includes-series-of-brief.html' title='Exception Handling Application Block'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-3102800287073759606</id><published>2010-03-03T22:45:00.001-08:00</published><updated>2010-03-03T22:45:48.744-08:00</updated><title type='text'>The Difference Between the HAVING and WHERE Clauses in a SQL Query</title><content type='html'>Though the HAVING clause specifies a condition that is similar to the purpose of a WHERE clause, the two clauses are not interchangeable. Listed below are some differences to help distinguish between the two: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1.The WHERE clause specifies the criteria which individual records must meet to be selcted by a query. It can be used without the GROUP BY clause. The HAVING clause cannot be used without the GROUP BY clause. &lt;br /&gt;&lt;br /&gt;2.The WHERE clause selects rows before grouping. The HAVING clause selects rows after grouping.&lt;br /&gt;&lt;br /&gt;3.The WHERE clause cannot contain aggregate functions. The HAVING clause can contain aggregate functions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-3102800287073759606?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/3102800287073759606/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=3102800287073759606' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3102800287073759606'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3102800287073759606'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/03/difference-between-having-and-where.html' title='The Difference Between the HAVING and WHERE Clauses in a SQL Query'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-7378831665351352706</id><published>2010-02-25T03:02:00.000-08:00</published><updated>2010-02-25T03:02:01.620-08:00</updated><title type='text'>ASP.NET Page Life Cycle Overview</title><content type='html'>In general terms, the page goes through the stages outlined in the following table. In addition to the page life-cycle stages, there are application stages that occur before and after a request but are not specific to a page. For more information, see ASP.NET Application Life Cycle Overview for IIS 7.0.&lt;br /&gt;&lt;br /&gt;Stage&lt;br /&gt; Description&lt;br /&gt; &lt;br /&gt;Page request&lt;br /&gt; The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.&lt;br /&gt; &lt;br /&gt;Start&lt;br /&gt; In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.&lt;br /&gt; &lt;br /&gt;Page initialization&lt;br /&gt; During page initialization, controls on the page are available and each control's UniqueID property is set. Any themes are also applied to the page. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.&lt;br /&gt; &lt;br /&gt;Load&lt;br /&gt; During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.&lt;br /&gt; &lt;br /&gt;Validation&lt;br /&gt; During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.&lt;br /&gt; &lt;br /&gt;Postback event handling&lt;br /&gt; If the request is a postback, any event handlers are called.&lt;br /&gt; &lt;br /&gt;Rendering&lt;br /&gt; Before rendering, view state is saved for the page and all controls. During the rendering phase, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream of the page's Response property.&lt;br /&gt; &lt;br /&gt;Unload&lt;br /&gt; Unload is called after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-7378831665351352706?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/7378831665351352706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=7378831665351352706' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7378831665351352706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7378831665351352706'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/aspnet-page-life-cycle-overview.html' title='ASP.NET Page Life Cycle Overview'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1799478998375542016</id><published>2010-02-25T03:00:00.001-08:00</published><updated>2010-02-25T03:00:59.090-08:00</updated><title type='text'>ASP.NET Application Life Cycle Overview</title><content type='html'>&lt;a href="http://msdn.microsoft.com/en-us/library/ms178473(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/ms178473(VS.80).aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1799478998375542016?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1799478998375542016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1799478998375542016' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1799478998375542016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1799478998375542016'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/aspnet-application-life-cycle-overview.html' title='ASP.NET Application Life Cycle Overview'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1172817962855371530</id><published>2010-02-25T02:26:00.000-08:00</published><updated>2010-02-25T03:05:53.057-08:00</updated><title type='text'>Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication</title><content type='html'>How Does It Work?&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa302376.aspx#secnetap04_topic2"&gt;http://msdn.microsoft.com/en-us/library/aa302376.aspx#secnetap04_topic2&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;J.D. Meier, Alex Mackman, Michael Dunner, and Srinath Vasireddy&lt;br /&gt;Microsoft Corporation&lt;br /&gt;Published: November 2002&lt;br /&gt;Last Revised: January 2006&lt;br /&gt;&lt;br /&gt;Applies to: &lt;br /&gt;Microsoft® ASP.NET&lt;br /&gt;Microsoft® Windows® 2000&lt;br /&gt;See the "patterns &amp;amp; practices Security Guidance for Applications Index" for links to additional security resources.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;See the Landing Page for the starting point and a complete overview of Building Secure ASP.NET Applications.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Summary: This appendix provides additional material to explain in more detail how certain key concepts and processes discussed within the main body of the guide actually work. (9 printed pages)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Contents&lt;br /&gt;IIS and ASP.NET Processing&lt;br /&gt;ASP.NET Pipeline Processing&lt;br /&gt;IIS and ASP.NET Processing&lt;br /&gt;Note The information in this section applies to Internet Information Services (IIS) 5, running on Windows® 2000.&lt;br /&gt;&lt;br /&gt;ASP.NET Web applications and Web services are processed by code that executes in a single instance of the ASP.NET worker process (aspnet_wp.exe), although on multi-processor computers, you can configure multiple instances, one per processor.&lt;br /&gt;&lt;br /&gt;IIS authenticates callers and creates a Windows access token for the caller. If anonymous access is enabled within IIS, then a Windows access token for the anonymous Internet user account (typically, IUSR_MACHINE) is created by IIS.&lt;br /&gt;&lt;br /&gt;Requests for ASP.NET file types are handled by an ASP.NET ISAPI extension (aspnet_isapi.dll), which runs in the IIS (inetinfo.exe) process address space. This uses a named pipe to communicate with the ASP.NET worker process as shown in Figure 1. IIS passes the Windows access token that represents the caller to the ASP.NET worker process. The ASP.NET Windows authentication module uses this to construct a WindowsPrincipal object and the ASP.NET File authorization module uses it to perform Windows access checks to ensure the caller is authorized to access the requested file.&lt;br /&gt;&lt;br /&gt;Figure 1. IIS and ASP.NET communication&lt;br /&gt;Note Access tokens are process relative. As a result, the ASP.NET ISAPI DLL running in inetinfo.exe calls DuplicateHandle to duplicate the token handle into the aspnet_wp.exe process address space and then passes the handle value through the named pipe. &lt;br /&gt;&lt;br /&gt;Application Isolation&lt;br /&gt;&lt;br /&gt;Separate application domains within the worker process (one per IIS virtual directory, or in other words, one per ASP.NET Web application or Web service) are used to provide isolation.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is in contrast to classic ASP, where the application protection level, configured within the IIS metabase determined whether the ASP application should execute in process with IIS (inetinfo.exe), out of process in a dedicated instance of Dllhost.exe, or in a shared (pooled) instance of Dllhost.exe.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Important The process isolation level setting within IIS has no affect on the way ASP.NET Web applications are processed. &lt;br /&gt;&lt;br /&gt;The ASP.NET ISAPI Extension&lt;br /&gt;&lt;br /&gt;The ASP.NET ISAPI extension (aspnet_isapi.dll) runs in the IIS process address space (inetinfo.exe) and forwards requests for ASP.NET file types to the ASP.NET worker process through a named pipe.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Specific ASP.NET file types are mapped to the ASP.NET ISAPI extension by mappings defined within the IIS metabase. Mappings for standard ASP.NET file types (including .aspx, .asmx, .rem, .soap) are established when the .NET Framework is installed. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To view application mappings &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1.From the Administrative Tools programs group, start Internet Information Services.&lt;br /&gt;&lt;br /&gt;2.Right-click the default Web site on your Web server computer, and then click Properties.&lt;br /&gt;&lt;br /&gt;3.Click the Home Directory tab, and then click Configuration. &lt;br /&gt;&lt;br /&gt;A list of mappings is displayed. You can see which file types are mapped to Aspnet_isapi.dll. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;IIS 6.0 and Windows Server&lt;br /&gt;&lt;br /&gt;IIS 6.0 on Windows Server will introduce some significant changes to the current process arrangement. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You will be able to configure multiple application pools, each served by one or more process instances (w3wp.exe). This will provide additional fault tolerance and manageability benefits and will allow you to isolate separate applications in separate processes.&lt;br /&gt;&lt;br /&gt;ASP.NET is integrated with the IIS 6.0 Kernel mode HTTP listener, which will allow requests to be passed directly from the operating system to the ASP.NET worker process.&lt;br /&gt;&lt;br /&gt;ASP.NET Pipeline Processing&lt;br /&gt;&lt;br /&gt;ASP.NET authentication and authorization mechanisms are implemented using HTTP module objects, which are invoked as part of the standard ASP.NET pipeline processing. Individual Web requests and responses pass through a pipeline of objects as shown in Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 2. ASP.NET pipeline processing&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The ASP.NET pipeline model consists of an HttpApplication object, various HTTP module objects, and an HTTP handler object, together with their associated factory objects, which have been omitted from Figure 2 for clarity. An HttpRuntime object is used at the start of the processing sequence and an HttpContext object is used throughout the lifecycle of a request to convey details about the request and response.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The following list explains the responsibilities and operations performed by the objects associated with the HTTP processing pipeline: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The HttpRuntime object examines the request received from IIS and dispatches it to an appropriate instance of the HttpApplication object to process the request. There is a pool of HttpApplication objects in each application domain in Aspnet_wp.exe. There is a one-to-one mapping between application domains, HttpApplication objects and IIS virtual directories. In other words, ASP.NET treats separate IIS virtual directories as separate applications. &lt;br /&gt;&lt;br /&gt;Note There is one instance of HttpRuntime in every Web application domain. &lt;br /&gt;&lt;br /&gt;The HttpApplication objects control the pipeline processing. An individual HttpApplication object is created to handle each simultaneous HTTP request. HttpApplication objects are pooled for performance reasons.&lt;br /&gt;&lt;br /&gt;HTTP module objects are filters that process HTTP request and response messages as they flow through the pipeline. They can view or alter the content of the request and response messages. HTTP modules are classes that implement IHttpModule.&lt;br /&gt;&lt;br /&gt;HTTP handler objects are the endpoints for HTTP requests and provide the request processing for specific file types. For example, one handler processes requests for *.aspx files while another processes requests for *.asmx files. The HTTP response message is generated and returned from the HTTP handler. HTTP handlers are classes that implement IHttpHandler.&lt;br /&gt;&lt;br /&gt;An HttpContext object is used throughout the pipeline to represent the current Web request and response. It is available to all modules in the pipeline and the handler object at the end of the pipeline. The HttpContext object exposes various properties including the User property which contains an IPrincipal object that represents the caller.&lt;br /&gt;&lt;br /&gt;The Anatomy of a Web Request&lt;br /&gt;&lt;br /&gt;The ASP.NET ISAPI library (Aspnet_isapi.dll) runs inside the IIS process address space (Inetinfo.exe). It dispatches requests to the HttpRuntime object within the ASP.NET worker process (Aspnet_wp.exe). The following set of actions occurs in response to each Web request received by ASP.NET: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The HttpRuntime object examines the request and forwards it to an instance of an HttpApplication object. &lt;br /&gt;&lt;br /&gt;There is at least one HttpApplication object instance per application domain (the objects are pooled) and one application domain per IIS virtual directory. The initial request for a file in a particular virtual directory results in a new application domain and a new HttpApplication object being created. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A list of HTTP modules is read from Machine.config (they are contained within the &amp;lt;httpModules&amp;gt; element). Additional custom HTTP modules can be added to Web.config for a specific application. The default &amp;lt;httpModules&amp;gt; element within Machine.config is shown in the following code snippet. Copy Code &amp;lt;httpModules&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add name="OutputCache" &lt;br /&gt;&lt;br /&gt;type="System.Web.Caching.OutputCacheModule"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add name="Session" &lt;br /&gt;&lt;br /&gt;type="System.Web.SessionState.SessionStateModule"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add name="WindowsAuthentication" &lt;br /&gt;&lt;br /&gt;type="System.Web.Security.WindowsAuthenticationModule"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add name="FormsAuthentication" &lt;br /&gt;&lt;br /&gt;type="System.Web.Security.FormsAuthenticationModule"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add name="PassportAuthentication" &lt;br /&gt;&lt;br /&gt;type="System.Web.Security.PassportAuthenticationModule"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add name="UrlAuthorization" &lt;br /&gt;&lt;br /&gt;type="System.Web.Security.UrlAuthorizationModule"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add name="FileAuthorization" &lt;br /&gt;&lt;br /&gt;type="System.Web.Security.FileAuthorizationModule"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/httpModules&amp;gt;&lt;br /&gt;&lt;br /&gt;The authentication modules hook the AuthenticateRequest event, while the authorization modules hook the AuthorizeRequest event. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The request passes through every module in the pipeline, although only a single authentication module is loaded. This depends on the configuration of the &amp;lt;authentication&amp;gt; element in Web.config. For example, the &amp;lt;authentication&amp;gt; element that follows results in the WindowsAuthenticationModule being loaded. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Copy Code &amp;lt;authentication mode="Windows" /&amp;gt;&lt;br /&gt;&lt;br /&gt;The activated authentication module is responsible for creating an IPrincipal object and storing it in the HttpContext.User property. This is vital, because the downstream authorization modules use this IPrincipal object in order to make authorization decisions. &lt;br /&gt;&lt;br /&gt;In the absence of authentication (for example, where anonymous access is enabled within IIS and ASP.NET is configured with &amp;lt;authentication mode="None" /&amp;gt;), there's a special non configured module that puts a default anonymous principal into the HttpContext. User property. As a result, HttpContext.User is always non-null after authentication. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you implement a custom authentication module, code within the custom module must create an IPrincipal object and store it in HttpContext.User, &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note ASP.NET also wires up Thread.CurrentPrincipal based on HttpContext.User after the AuthenticateRequest event.&lt;br /&gt;&lt;br /&gt;The HttpApplication fires the AuthenticateRequest event, which can be hooked in global.asax. This allows you to inject custom processing code; for example, to load the set of roles associated with the current user. However, note that the WindowsAuthenticationModule does this automatically. The role list is obtained from the set of Windows groups in which the authenticated Windows user is a member.&lt;br /&gt;&lt;br /&gt;After the appropriate authentication module has finished its processing, the authorization modules are called if the request hasn't been aborted.&lt;br /&gt;&lt;br /&gt;When the UrlAuthorizationModule is called, it checks for an &amp;lt;authorization&amp;gt; tag in Machine.config and Web.config. If present, it retrieves the IPrincipal object from HttpContext.User and checks to see whether the user is authorized to access the requested resource using the specified verb (GET, POST, and so on). &lt;br /&gt;&lt;br /&gt;If the user is not authorized, the UrlAuthorizationModule calls HttpApplication.CompleteRequest, which aborts normal message processing. The UrlAuthorizationModule returns an HTTP 401 status code. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Next, the FileAuthorizationModule is called. It checks whether the IIdentity object in HttpContext.User.Identity is an instance of the WindowsIdentity class. &lt;br /&gt;&lt;br /&gt;If the IIdentity object is not a WindowsIdentity, the FileAuthorizationModule performs no further processing. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If a WindowsIdentity is present, the FileAuthorizationModule calls the AccessCheck API (through P/Invoke) to see if the authenticated caller (whose access token has been passed to ASP.NET by IIS and is exposed by the WindowsIdentity object) is authorized to access the requested file. If the file's security descriptor contains at least a Read ACE in its DACL, the request is allowed to proceed. Otherwise the FileAuthorizationModule calls HttpApplication.CompleteRequest and returns a 401 status code. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Forms authentication processing&lt;br /&gt;&lt;br /&gt;The FormsAuthenticationModule is activated when the following element is in Web.config.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Copy Code &amp;lt;authentication mode="Forms" /&amp;gt;&lt;br /&gt;&lt;br /&gt;Remember that for Forms authentication, you implement the Application_Authenticate event in Global.asax. For Forms authentication, the following sequence occurs: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Within this code, you can construct an IPrincipal object and store it in HttpContext.User. This typically contains the role list retrieved from a custom data store (normally a SQL Server database or Active Directory). The IPrincipal object is typically an instance of the GenericPrincipal class but could also be a custom IPrincipal class. &lt;br /&gt;&lt;br /&gt;The FormsAuthenticationModule checks to see if you have created an IPrincipal object. If you have, it is used by the downstream authorization modules. If you haven't, the FormsAuthenticationModule constructs a GenericPrincipal (with no roles) and stores it in the context. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If there is no role information, any authorization checks (such as PrincipalPermssion demands) that demand role membership, will fail. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The UrlAuthorizationModule handles the AuthorizeRequest event. Its authorization decisions are based on the IPrincipal object contained within HttpContext.User.&lt;br /&gt;&lt;br /&gt;Windows authentication processing&lt;br /&gt;&lt;br /&gt;The WindowsAuthenticationModule is activated when the following element is in Web.config.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Copy Code &amp;lt;authentication mode="Windows" /&amp;gt;&lt;br /&gt;&lt;br /&gt;For Windows authentication, the following sequence occurs: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1.The WindowsAuthenticationModule creates a WindowsPrincipal object using the Windows access token passed to ASP.NET by IIS.&lt;br /&gt;&lt;br /&gt;2.It uses P/Invoke to call Win32 functions to obtain the list of Windows group that the user belongs to. These are used to populate the WindowsPrincipal role list.&lt;br /&gt;&lt;br /&gt;3.It stores the WindowsPrincipal object in HttpContext.User, ready to be used by the downstream authorization modules.&lt;br /&gt;&lt;br /&gt;Event Handling&lt;br /&gt;&lt;br /&gt;The HttpApplication object fires the set of events shown in Table 1. Individual HTTP modules can hook these events (by providing their own event handlers).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Table 1. Events fired by HttpApplication objects&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Event Notes &lt;br /&gt;&lt;br /&gt;BeginRequest Fired before request processing starts &lt;br /&gt;&lt;br /&gt;AuthenticateRequest To authenticate the caller &lt;br /&gt;&lt;br /&gt;AuthorizeRequest To perform access checks &lt;br /&gt;&lt;br /&gt;ResolveRequestCache To get a response from the cache &lt;br /&gt;&lt;br /&gt;AcquireRequestState To load session state &lt;br /&gt;&lt;br /&gt;PreRequestHandlerExecute Fired immediately before the request is sent to the handler object &lt;br /&gt;&lt;br /&gt;PostRequestHandlerExecute Fired immediately after the request is sent to the handler object &lt;br /&gt;&lt;br /&gt;ReleaseRequestState To store session state &lt;br /&gt;&lt;br /&gt;UpdateRequestCache To update the response cache &lt;br /&gt;&lt;br /&gt;EndRequest Fired after processing ends &lt;br /&gt;&lt;br /&gt;PreSendRequestHeaders Fired before buffered response headers are sent &lt;br /&gt;&lt;br /&gt;PreSendRequestContent Fired before buffered response body sent &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note The HTTP handler executes in between the PreRequestHandlerExecute and PostRequestHandlerExecute events.&lt;br /&gt;&lt;br /&gt;The last two events are non-deterministic and could occur at any time (for example, as a result of a Response.Flush). All other events are sequential. &lt;br /&gt;&lt;br /&gt;You do not need to implement an HTTP module simply in order to hook one of these events. You can also add event handlers to Global.asax. In addition to the events listed in Table 1 (which can all be hooked by individual HTTP module objects), the HttpApplication object fires Application_OnStart and Application_OnEnd handlers, which will be familiar to ASP developers. These can be handled only within Global.asax. Finally, you can also implement custom event handlers within Global.asax for events fired by individual HTTP module objects. For example, the session state module fires Session_OnStart and Session_OnEnd events.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Implementing a Custom HTTP Module&lt;br /&gt;&lt;br /&gt;To create your own HTTP module and insert it into the ASP.NET processing pipeline &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1.Create a class that implements IHttpModule.&lt;br /&gt;&lt;br /&gt;2.Place the assembly that contains the module in your application's \bin subdirectory or you can install it into the Global Assembly Cache.&lt;br /&gt;&lt;br /&gt;3.Add an &amp;lt;HttpModules&amp;gt; element to your application's web.config, as shown below. Copy Code &amp;lt;system.web&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;httpModules&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add name="modulename"&lt;br /&gt;&lt;br /&gt;type="namespace. classname, assemblyname" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/httpModules&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/system.web&amp;gt;&lt;br /&gt;&lt;br /&gt;Implementing a Custom HTTP Handler&lt;br /&gt;&lt;br /&gt;You may need to implement a custom HTTP handler, for example to handle the processing of files with the .data file extension.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To implement a custom HTTP handler &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1.Add a mapping to the IIS metabase to map the .data file extension to the ASP.NET ISAPI extension (Aspnet_isapi.dll). &lt;br /&gt;&lt;br /&gt;Right-click your application's virtual directory in the IIS MMC snap-in, click the Configuration button, and then click Add to create a new mapping for .data files to C:\Winnt\Microsoft.NET\Framework\v1.0.3705\aspnet_isapi.dll. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note If you select the Check that file exists check box when adding the mapping, then the file must be physically present. This is usually what is wanted unless you have virtualized paths that don't map to a physical file. Virtualized paths ending with .rem or .soap are used by .NET Remoting.&lt;br /&gt;&lt;br /&gt;2.Create a class that implements IHttpHandler (and optionally IHttpAsyncHandler if you want to handle requests asynchronously).&lt;br /&gt;&lt;br /&gt;3.Place the assembly that contains the handler in your application's \bin subdirectory or you can install it into the Global Assembly Cache.&lt;br /&gt;&lt;br /&gt;4.Add the handler to the processing pipeline by adding an &amp;lt;httpHandlers&amp;gt; section to your application's Web.config file. Copy Code &amp;lt;system.web&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;httpHandlers&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;add verb="*" path="*.data" type="namespace.classname, assemblyname" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/httpHandlers&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/system.web&amp;gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1172817962855371530?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1172817962855371530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1172817962855371530' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1172817962855371530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1172817962855371530'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/building-secure-aspnet-applications.html' title='Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-49016672488978315</id><published>2010-02-25T01:10:00.001-08:00</published><updated>2010-02-25T01:10:32.610-08:00</updated><title type='text'>Understanding IIS Isolation Levels</title><content type='html'>Internet Information Server introduced the notion "Isolation Level", which is also present in IIS4 under a different name. IIS5 supports three isolation levels, that you can set from the Home Directory tab of the site's Properties dialog: &lt;br /&gt;&lt;br /&gt;•Low (IIS Process): ASP pages run in INetInfo.Exe, the main IIS process, therefore they are executed in-process. This is the fastest setting, and is the default under IIS4. The problem is that if ASP crashes, IIS crashes as well and must be restarted (IIS5 has a reliable restart feature that automatically restarts a server when a fatal error occurs). &lt;br /&gt;&lt;br /&gt;•Medium (Pooled): In this case ASP runs in a different process, which makes this setting more reliable: if ASP crashes IIS won't. All the ASP applications at the Medium isolation level share the same process, so you can have a web site running with just two processes (IIS and ASP process). IIS5 is the first Internet Information Server version that supports this setting, which is also the default setting when you create an IIS5 application. Note that an ASP application that runs at this level is run under COM+, so it's hosted in DLLHOST.EXE (and you can see this executable in the Task Manager). &lt;br /&gt;&lt;br /&gt;•High (Isolated): Each ASP application runs out-process in its own process space, therefore if an ASP application crashes, neither IIS nor any other ASP application will be affected. The downside is that you consume more memory and resources if the server hosts many ASP applications. Both IIS4 and IIS5 supports this setting: under IIS4 this process runs inside MTS.EXE, while under IIS5 it runs inside DLLHOST.EXE. &lt;br /&gt;&lt;br /&gt;When selecting an isolation level for your ASP application, keep in mind that out-process settings - that is, Medium and High - are less efficient then in-process (Low). However, out-process communication has been vastly improved under IIS5, and in fact IIS5's Medium isolation level often deliver better results than IIS4's Low isolation. In practice, you shouldn't set the Low isolation level for an IIS5 application unless you really need to serve hundreds pages per second.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-49016672488978315?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/49016672488978315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=49016672488978315' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/49016672488978315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/49016672488978315'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/understanding-iis-isolation-levels.html' title='Understanding IIS Isolation Levels'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4321877924418469129</id><published>2010-02-25T01:01:00.000-08:00</published><updated>2010-02-25T01:01:15.114-08:00</updated><title type='text'>Session State Managemnet</title><content type='html'>Session State&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ASP.NET provides the cross-request state information (shopping carts, data scrolling, and so on) infrastructure that Web applications require, with built-in session-state functionality that enables you to take the following actions: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Automatically identify and classify requests coming from a single browser client into a logical application session on the server.&lt;br /&gt;&lt;br /&gt;Store session-scoped data on the server for use across multiple browser requests.&lt;br /&gt;&lt;br /&gt;Raise appropriate session-lifetime management events (Session_OnStart, Session_OnEnd, and so on) that can be handled in application code. &lt;br /&gt;&lt;br /&gt;Note The Session_OnEnd event is supported only the in-process session-state mode. This event is not raised if you use State Server or SQL Server modes.&lt;br /&gt;&lt;br /&gt;Automatically release session data if the browser does not revisit an application within a specified time-out period.&lt;br /&gt;&lt;br /&gt;This topic provides an overview of session state, describes how active ASP.NET sessions are identified and tracked, explains the session-state store and general structure, and concludes with a high-level code example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Session State Overview&lt;br /&gt;&lt;br /&gt;HTTP is a stateless protocol, which means that it does not automatically indicate whether a sequence of requests is all from the same client or even whether a single browser instance is still actively viewing a page or site. As a result, building Web applications that need to maintain some cross-request state information (shopping carts, data scrolling, and so on) can be extremely challenging without additional infrastructure help.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ASP.NET provides the following support for sessions: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A session-state facility that is easy to use, familiar to ASP developers, and consistent with other .NET Framework APIs.&lt;br /&gt;&lt;br /&gt;A reliable session-state facility that can survive Internet Information Services (IIS) restarts and worker-process restarts without losing session data.&lt;br /&gt;&lt;br /&gt;A scalable session-state facility that can be used in both Web farm (multicomputer) and Web garden (multiprocess) scenarios and that enables administrators to allocate more processors to a Web application to improve its scalability.&lt;br /&gt;&lt;br /&gt;A session-state facility that works with browsers that do not support HTTP cookies.&lt;br /&gt;&lt;br /&gt;A throughput equivalent to that of ASP (or better) for core session-state scenarios (50/50 read/write when putting items into shopping carts, modifying last page visited, validating credit card details, and so on).&lt;br /&gt;&lt;br /&gt;Session state, however, does not persist across Web application boundaries. If a Web application switches to another application during execution, the session information is not available to the new application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Identifying a Session&lt;br /&gt;&lt;br /&gt;Each active ASP.NET session is identified and tracked using a 120-bit SessionID string containing only the ASCII characters that are allowed in URLs. SessionID values are generated using an algorithm that guarantees uniqueness so that sessions do not collide, and randomness so that a malicious user cannot use a new SessionID to calculate the SessionID of an existing session.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The SessionID strings are communicated across client-server requests either by means of an HTTP cookie or a modified URL with the SessionID string embedded, depending on how you configure the application settings.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Session-State Store&lt;br /&gt;&lt;br /&gt;ASP.NET provides a simple and easy-to-use session-state model that you can use to store arbitrary data and objects across multiple Web requests. It accomplishes this using a dictionary-based, in-memory cache of object references that live within the IIS process. When using the in-process session-state mode consider the following limitations: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;When using the in-process session-state mode, session-state data is lost if aspnet_wp.exe or the application domain restarts. These restarts commonly occur in the following circumstances: &lt;br /&gt;&lt;br /&gt;Setting an attribute in the &lt;processmodel&gt;element of the application's Web.config file that causes a new process to start when a condition is met, such as memoryLimit.&lt;br /&gt;&lt;br /&gt;The Global.asax or Web.config file is modified.&lt;br /&gt;&lt;br /&gt;Changes to the \Bin directory of the Web application.&lt;br /&gt;&lt;br /&gt;Antivirus software scans and modifies the Global.asax file, the Web.config file, or a file in the \Bin directory of the Web application. &lt;br /&gt;&lt;br /&gt;If you enable Web garden mode in the &lt;processmodel&gt;element of the application's Web.config file, do not use in-process session-state mode. Otherwise, random data loss can occur.&lt;br /&gt;&lt;br /&gt;Instead of keeping live objects, the .NET State Server simply stores session state in memory when in out-of-proc mode. In this mode the worker process talks directly to the State Server. In SQL mode, session states are stored in a SQL Server database and the worker process talks directly to SQL. The ASP.NET worker processes are then able to take advantage of this simple storage service by serializing and saving (using .NET serialization services) all objects within a client's Session collection at the end of each Web request. When the client revisits the server, the relevant ASP.NET worker process retrieves these objects from the State Server as binary streams, deserializes them into live instances, and places them back into a new Session collection object exposed to the request handler.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In SQL mode, session state can also be configured to work in a failover cluster. A failover cluster is two or more identical, redundant Web servers that store their session data on a separate computer in a SQL Server database. For information on how to set up this configuration, see Configuring SQL Server Mode.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;By cleanly separating the storage of session data from the application's use of it, ASP.NET supports several powerful scenarios that were unavailable with earlier versions of ASP: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Recovery from application crashes, because the memory used for session state is not within the ASP.NET worker process. &lt;br /&gt;&lt;br /&gt;Because all state is stored separately from an individual worker process, it is not lost if the process crashes due to an access violation or is forcibly restarted by the IIS Admin Service in the event of a deadlock or memory leak. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Partitioning an application across multiple worker processes. &lt;br /&gt;&lt;br /&gt;Because all state is stored separately from worker processes, you can cleanly partition an application across multiple processes. Such partitioning can dramatically improve both the availability and the scalability of an application on multiple-process computers. Moreover, because it associates each worker process with a single computer, ASP.NET is able to eliminate cross-processor lock contention, one of the major scalability bottlenecks in earlier versions of ASP. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Partitioning an application across multiple Web farm computers. &lt;br /&gt;&lt;br /&gt;Because all state is stored separately from worker processes, you can partition an application across multiple worker processes running on multiple computers. The model for communicating state between a worker process and a state service running on different computers is almost the same as that for processes and servers running on the same computer. In either case there can only be one State Server per Web farm. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Session State Structure&lt;br /&gt;&lt;br /&gt;ASP.NET-based applications use an event-based execution organization to enable multiple .NET Framework class modules to participate in the processing of a single Web request.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The SessionState Module&lt;br /&gt;&lt;br /&gt;The .NET Framework implements session state through the SessionStateModule class (derived from IHttpModule), which participates in the execution of each request received by a .NET-based application. The SessionStateModule is responsible for either generating or obtaining unique SessionID strings and for storing and retrieving state data from an external state provider.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Session State Collections&lt;br /&gt;&lt;br /&gt;The SessionState class exposes two state collections: Contents and StaticObjects. The Contents collection exposes all variable items that have been added to the session-state collection directly through code. For example:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Visual Basic] Copy Code ' Visual Basic code from within a page, a handler, or Global.asax.&lt;br /&gt;&lt;br /&gt;Session("Message") = "MyMsg"&lt;br /&gt;&lt;br /&gt;Session("AppStartTime") = Now&lt;br /&gt;&lt;br /&gt;[C#]&lt;br /&gt;&lt;br /&gt;// C# code from within a page, a handler, or Global.asax.&lt;br /&gt;&lt;br /&gt;Session["Message"] = "MyMsg";&lt;br /&gt;&lt;br /&gt;Session["AppStartTime"] = DateTime.Now;For compatibility with earlier versions of ASP, these values also can be accessed through a Contents property on the application object, as in the following example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[Visual Basic] Copy Code ' Visual Basic code from within a page, a handler, or Global.asax.&lt;br /&gt;&lt;br /&gt;Session.Contents("Message") = "MyMsg"&lt;br /&gt;&lt;br /&gt;Session.Contents("AppStartTime") = Now&lt;br /&gt;&lt;br /&gt;[C#]&lt;br /&gt;&lt;br /&gt;// C# code from within a page, a handler, or Global.asax.&lt;br /&gt;&lt;br /&gt;Session.Contents["Message"] = "MyMsg";&lt;br /&gt;&lt;br /&gt;Session.Contents["AppStartTime"] = DateTime.Now;The StaticObjects collection exposes all variable items that have been added to the session-state collection through&lt;object althtml=" tags with the scope of &amp;quot;Session&amp;quot; within the Global.asax file. For example:&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Copy Code ' Global.asax definition.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;OBJECT RUNAT=&amp;quot;SERVER&amp;quot; SCOPE=&amp;quot;SESSION&amp;quot; ID=&amp;quot;MyInfo&amp;quot; PROGID=&amp;quot;Scripting.Dictionary&amp;quot;&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/OBJECT&amp;gt;Objects cannot be added to the StaticObjects collection from anywhere else within an ASP.NET application. The collection throws a NotSupportedException if users attempt to add objects directly through code.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Note The ASP.NET page compiler automatically injects member references into all objects stored within the StaticObjects collection at page compilation time.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Page developers can access Session objects directly at page request time without having to go through the StaticObjects collection, as shown in the following example:&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Copy Code &amp;lt;html&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Number of entries: &amp;lt;%= MyInfo.Count %&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;body&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/html&amp;gt;Session State Configuration and Startup&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;There are three session state modes in ASP.NET. You can choose between in-process, State Server, and SQL Server. Regardless of which mode you choose, the basic configuration process is the same.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;ASP.NET configures session state in two stages. First, the session state module is inserted in the HTTP request. By default this is done at the root of the configuration hierarchy in the computer-wide Machine.config file.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;The following example shows a sample entry in the Machine.config file. For the configuration file to work correctly, you must provide the fully qualified assembly name to the appropriate version of the System.Web.SessionState.SessionStateModule assembly. This version is usually the version that is associated with the .NET Framework version used by your application. For information on how to obtain the fully qualified assembly name, see Assembly Names.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Copy Code &amp;lt;httpmodules&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;...&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;!-- You must supply a valid fully qualified assembly name here. --&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;!-- For this example to work correctly, the version number for --&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;!-- the referenced assemby must match the version installed on --&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;!-- your computer by the .NET Framework. --&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;add name=&amp;quot;sessionState&amp;quot; type=&amp;quot;System.Web.SessionState.SessionStateModule, Version=1.0.3300.0,Culture=neutral,PublicKeyToken=b77a5c561934e089&amp;quot; /&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;...&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/httpmodules&amp;gt;Then, depending on which session state mode you want to use, set the appropriate session state service attributes in the &amp;lt;sessionState&amp;gt; configuration element.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Configuring In-process Mode&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;In-process is the default session state mode. To use in-process mode, set the mode attribute of the &amp;lt;sessionState&amp;gt; element to Inproc.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;The following shows a sample configuration setting for in-process mode.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Copy Code &amp;lt;configuration&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;system.web&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;sessionState mode=&amp;quot;Inproc&amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;cookieless=&amp;quot;false&amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;timeout=&amp;quot;20&amp;quot;/&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/sessionState&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/system.web&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/configuration&amp;gt;Configuring State Server Mode&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;To use State Server, you must first make sure ASP.NET state service is running on the remote server used for the session store. This service is installed with ASP.NET and Visual Studio .NET at the following location:&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;systemroot\Microsoft.NET\Framework\versionNumber\aspnet_state.exe &amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Next, set the mode attribute of the &amp;lt;sessionState&amp;gt; element to StateServer in the Web.config file of the application. Finally, set the connectionString attribute to tcpip=serverName:portNumber.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;The following shows a sample configuration setting for State Server mode.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Copy Code &amp;lt;configuration&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;system.web&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;sessionState mode=&amp;quot;StateServer&amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;stateConnectionString=&amp;quot;tcpip=dataserver:42424&amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;cookieless=&amp;quot;false&amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;timeout=&amp;quot;20&amp;quot;/&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/sessionState&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/system.web&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/configuration&amp;gt;Configuring SQL Server Mode&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;To use SQL Server, first run either InstallSqlState.sql or InstallPersistSqlState.sql on the computer with SQL Server that will store the session state. Both scripts create a database called ASPState that includes several stored procedures. The difference between the scripts is where the ASPStateTempApplications and ASPStateTempSessions tables are placed. The InstallSqlState.sql script adds these tables to the TempDB database, which loses session data if the computer is restarted. The InstallPersistSqlState.sql script, on the other hand, adds these tables to the ASPState database, which allows session data to be retained when the computer is restarted.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Both of these script files are installed by default at the following location:&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;systemroot\Microsoft.NET\Framework\versionNumber&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Next, set the mode attribute of the &amp;lt;sessionState&amp;gt; element to SQLServer in the Web.config file of the application. Finally, set the sqlConnectionString attribute to Integrated Security=SSPI;data source=serverName;.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;The following shows a sample configuration setting for SQL Server mode.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Copy Code &amp;lt;configuration&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;system.web&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;sessionState mode=&amp;quot;SQLServer&amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;sqlConnectionString=&amp;quot; Integrated Security=SSPI;data source=dataserver;&amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;cookieless=&amp;quot;false&amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;timeout=&amp;quot;20&amp;quot;/&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/sessionState&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/system.web&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/configuration&amp;gt;In SQL Server mode, session state can also be configured to work in a failover cluster. A failover cluster is two or more identical, redundant Web servers that store their session data on a separate computer in a SQL Server database. If a Web server fails, another server in the cluster can take over and serve requests without session data loss. To configure a failover cluster, set the &amp;lt;machinekey&amp;gt; element in the Web.config file of the Web servers to the same value. Then set the SQL connection string of the Web servers to point to the SQL Server database on the computer that stores the session data. &amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;High-Level Code Example&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;The following example shows how to access existing session-state data in a read-only manner to dynamically generate a page containing user information and personal stock portfolio information.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;[Visual Basic] Copy Code &amp;lt;%@ Language=VB EnableSessionState=true %&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;html&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;script runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;' Obtain data table of user's personal stock data.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Dim MyStocks as DataTable&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Dim Stock as DataRow&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;MyStocks = _&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;CType(Session(&amp;quot;PersonalStockData&amp;quot;), DataTable)&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;' Update HTML output with session values.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Name.InnerText = Session(&amp;quot;FirstName&amp;quot;).ToString()&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;SpouseVal.InnerText = Session(&amp;quot;SpouseName&amp;quot;).ToString()&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;For Each Stock In MyStocks.Rows&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;StockList.AddItem(Stock(&amp;quot;Symbol&amp;quot;) &amp;amp;amp; &amp;quot;: &amp;quot; &amp;amp;amp; Stock(&amp;quot;Name&amp;quot;))&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Next&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;End Sub&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;body&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Hi &amp;lt;span id=&amp;quot;Name&amp;quot; runat=server/&amp;gt;, your spouse is: &amp;lt;span id=&amp;quot;SpouseVal&amp;quot; runat=&amp;quot;server&amp;quot;/&amp;gt;.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Here are the stocks you and your spouse currently own:&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;acme:listbox id=&amp;quot;StockList&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;! — List box is dynamically populated from code. --&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/acme:listbox&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/html&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;[C#]&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;%@ Language=C# EnableSessionState=true %&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;html&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;head&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;script runat=server&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;void Page_Load(Object Sender, EventArgs E) {&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;// Obtain data table of user's personal stock data.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;DataTable MyStocks =&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;(DataTable)Session[&amp;quot;PersonalStockData&amp;quot;];&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;// Update HTML output with session values.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Name.InnerText = Session[&amp;quot;FirstName&amp;quot;].ToString();&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;SpouseVal.InnerText = Session[&amp;quot;SpouseName&amp;quot;].ToString();&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;foreach (DataRow Stock in MyStocks.Rows) {&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;StockList.AddItem(Stock[&amp;quot;Symbol&amp;quot;] + &amp;quot;: &amp;quot;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;+ Stock[&amp;quot;Name&amp;quot;]);&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;}&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;}&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/head&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;body&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Hi &amp;lt;span id=&amp;quot;Name&amp;quot; runat=&amp;quot;server&amp;quot;/&amp;gt;, your spouse is: &amp;lt;span id=&amp;quot;SpouseVal&amp;quot; runat=&amp;quot;server&amp;quot;/&amp;gt;.&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;Here are the stocks you and your spouse currently own:&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;acme:listbox id=&amp;quot;StockList&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;! — List box is dynamically populated from code. --&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/acme:listbox&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/P&amp;gt;&amp;lt;P&amp;gt;&amp;lt;/html&amp;gt;&amp;lt;/P&amp;gt;" runat="server"&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4321877924418469129?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4321877924418469129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4321877924418469129' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4321877924418469129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4321877924418469129'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/session-state-managemnet.html' title='Session State Managemnet'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-3601874569636561543</id><published>2010-02-25T00:47:00.001-08:00</published><updated>2010-02-25T00:47:59.756-08:00</updated><title type='text'>The ASP.NET Worker Process</title><content type='html'>ASP.NET runs within a process known as the ASP.NET worker process. All ASP.NET functionality runs within the scope of this process.&lt;br /&gt;&lt;br /&gt;A regular Web server contains only a single ASP.NET worker process. This is different from both Web farms and Web gardens: &lt;br /&gt;&lt;br /&gt;A Web farm contains multiple ASP.NET worker processes. &lt;br /&gt;Each server in the group of servers handles a separate ASP.NET worker process. &lt;br /&gt;&lt;br /&gt;A Web garden contains multiple ASP.NET worker processes. &lt;br /&gt;Each CPU in the SMP server handles a separate ASP.NET worker process. &lt;br /&gt;&lt;br /&gt;Choosing an ASP.NET worker process&lt;br /&gt;&lt;br /&gt;When a Web client connects to a Web farm or Web garden, one of the multiple ASP.NET worker processes is selected to run the request. &lt;br /&gt;&lt;br /&gt;In a Web farm, Network Load Balancing determines the ASP.NET worker process selected.&lt;br /&gt;In a Web garden, the ASP.NET worker process selected is determined by ASP.NET.&lt;br /&gt;State management with multiple ASP.NET worker processes&lt;br /&gt;&lt;br /&gt;When moving from a scenario with a single ASP.NET worker process (a normal Web server) to a scenario with multiple ASP.NET worker processes (a Web farm or Web garden), complications with state management are introduced.&lt;br /&gt;&lt;br /&gt;Web pages are stateless, so a Web server must persist state through other means. Typical means to manage state on the Web server include Session State and the ASP.NET Cache.&lt;br /&gt;&lt;br /&gt;Note   Issues of persistence and state (within a single Web server) are discussed in detail in the section Which Persistence Approach Should I Use with Crystal Reports?.&lt;br /&gt;Both Session and Cache are contained within the memory space of a single ASP.NET worker process. But in a Web farm or Web garden, multiple ASP.NET worker processes work together simultaneously. The Session or Cache within any individual ASP.NET worker process cannot manage state across multiple processes.&lt;br /&gt;&lt;br /&gt;Therefore, an additional layer is required for state management: an out-of-process Session State server that stores and retrieves state information for every ASP.NET worker process in the Web farm or Web garden.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-3601874569636561543?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/3601874569636561543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=3601874569636561543' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3601874569636561543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3601874569636561543'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/aspnet-worker-process.html' title='The ASP.NET Worker Process'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-8351987950493319865</id><published>2010-02-25T00:45:00.001-08:00</published><updated>2010-02-25T00:45:55.607-08:00</updated><title type='text'>Web Farm Architecture</title><content type='html'>A Web farm has multiple servers that are exposed to browser clients as a single virtual server, with one virtual Media Access Card and TCP/IP address. &lt;br /&gt;&lt;br /&gt;Behind this virtual layer, each server in the Web farm receives every network packet, but only processes a subset of those packets. The ability to equally share the workload is what gives Web farms their superior processing power.&lt;br /&gt;&lt;br /&gt;This distribution of packets is managed by Network Load Balancing. Network Load Balancing does the following: &lt;br /&gt;&lt;br /&gt;It balances the client requests between servers.&lt;br /&gt;It determines which server will process which request.&lt;br /&gt;It ensures that server resource use and client wait times are optimized.&lt;br /&gt;It provides a superior alternative to client affinity. &lt;br /&gt;Note   In a client affinity scenario, connecting clients are restricted to return to the same server each time.&lt;br /&gt;Client affinity is usually turned off, because it can create a bottleneck of requests for a particular server.&lt;br /&gt;Each server on a Web farm has a Network Load Balancing network device driver, which communicates with the other servers, and each server typically has two network cards. The second card allows internal communications for Network Load Balancing to be done over a separate, internal network.&lt;br /&gt;&lt;br /&gt;The Network Load Balancing network device driver is provided in the following operating systems: &lt;br /&gt;&lt;br /&gt;Windows 2000 Advanced Server.&lt;br /&gt;Windows Advanced Server 2003.&lt;br /&gt;Web garden architecture&lt;br /&gt;&lt;br /&gt;A Web garden is like a Web farm, except that rather than use several server machines linked together, it uses single machine with multiple CPUs.&lt;br /&gt;&lt;br /&gt;This single SMP (symmetric multiprocessing) server uses ASP.NET to run a separate ASP.NET worker process on each CPU. The server manages multiple client requests against the multiple CPUs on the server.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-8351987950493319865?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/8351987950493319865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=8351987950493319865' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8351987950493319865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8351987950493319865'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/web-farm-architecture.html' title='Web Farm Architecture'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-5212523003769292512</id><published>2010-02-20T02:59:00.000-08:00</published><updated>2010-02-20T02:59:58.775-08:00</updated><title type='text'>Can .dll files check-in to TFS Source Control?</title><content type='html'>The answer is yes.&lt;br /&gt;&lt;br /&gt;When creating a web project in Visual Studio .NET 2005, the bin folder gets exposed to TFS source control. &lt;br /&gt;&lt;br /&gt;Normally, the bin folder is how the web project keeps track of the project references.  When a project reference is added to the project, the .dll is copied to the bin directory. &lt;br /&gt;&lt;br /&gt;In a source controlled environment, this copy is "noticed" by Visual Studio 2005 and exposed to the source control process. This means that you can check in all the .dlls added to the bin folder. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;The Bin folder is not visible on the Source Control Window. So, when you checked in the .dll files, the files will be drop on the drop release folder.&lt;br /&gt;&lt;br /&gt;I don't see why we need to put bin folder into our source control. It is not a wise idea bro. If you want to put your dll, let say external dll or third party library such as nhibernate.dll or P&amp;P EntLib dlls, put it in another folder other than bin, obj, debug..etc..if you 're developing multitier apps or seperate your module into several projects, it is much easier because you can just Add Reference to you projects instead of refer to dll. &lt;br /&gt;In our development team here, we organise all our tools, and libraries properly, put it into the right folder.Example: put all the externall dlls into a folder named 'Library'. When new developer join our team. they can just get latest the root folder, then he can compile the solution without any problem.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-5212523003769292512?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/5212523003769292512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=5212523003769292512' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5212523003769292512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5212523003769292512'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/can-dll-files-check-in-to-tfs-source.html' title='Can .dll files check-in to TFS Source Control?'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-6002706548037411883</id><published>2010-02-11T06:01:00.000-08:00</published><updated>2010-02-11T06:01:41.183-08:00</updated><title type='text'>Should I use an abstract class or an interface?</title><content type='html'>The functionality available through the use of abstract classes and of interfaces is quite similar. However, each has its pros and cons. &lt;br /&gt;&lt;br /&gt;Contents [hide]&lt;br /&gt;1 Inheritance &lt;br /&gt;1.1 Single inheritance&lt;br /&gt;1.2 Value type polymorphism&lt;br /&gt;2 Separation of contract and implementation&lt;br /&gt;3 Versioning&lt;br /&gt;4 Design flexibility&lt;br /&gt;5 Visual C# Best Practices &lt;br /&gt;5.1 Use an abstract class&lt;br /&gt;5.2 Use an interface&lt;br /&gt;6 Summary&lt;br /&gt;7 See also&lt;br /&gt; &lt;br /&gt;Inheritance &lt;br /&gt;A C# class may only subclass—inherit from—one other class. Therefore, by inheriting from (subclassing) an abstract class, the derived class has used up its ability to participate in a meaningful type hierarchy. &lt;br /&gt;&lt;br /&gt;On the other hand, a class can implement—inherit from—any number of interfaces. And, it can still inherit from (subclass) a base class which makes sense. &lt;br /&gt;&lt;br /&gt;Single inheritance&lt;br /&gt;C# supports single inheritance: C# does not support multiple inheritance from multiple classes like C++ does. But, by using abstract classes and interfaces, C# programs can achieve most of the same functionality without the confusion and maintenance problems associated with multiple inheritance. &lt;br /&gt;&lt;br /&gt;Value type polymorphism&lt;br /&gt;.NET value types are objects descending from Object; but, they cannot inherit from other types. They can implement interfaces. Thus, primitives—such as Int32— can implement the IComparable interface, for example, making them comparable. &lt;br /&gt;&lt;br /&gt;Separation of contract and implementation &lt;br /&gt;Interfaces separate the syntax rather than the semantic contract from the implementation. Classes can be designed to decouple the semantic contract from the implementation. For example, abstract classes can be separated in a different assembly than their concrete implementations. &lt;br /&gt;&lt;br /&gt;Versioning &lt;br /&gt;An abstract class can contain an interface plus implementations. This simplifies versioning. An abstract class can be extended by adding new nonabstract methods with default implementations. Also, a convenience method is easily added to an abstract class. &lt;br /&gt;&lt;br /&gt;An interface cannot be modified without breaking its contract with the classes which implement it. Once an interface has been shipped, its member set is permanently fixed. An API based on interfaces can only be extended by adding new interfaces. &lt;br /&gt;&lt;br /&gt;Design flexibility &lt;br /&gt;Interfaces offer more design flexibility; precisely because, they can be implemented by any class regardless of its type hierarchy. &lt;br /&gt;&lt;br /&gt;Visual C# Best Practices &lt;br /&gt;Use abstract classes and interfaces in combination to optimize your design trade-offs. &lt;br /&gt;Use an abstract class &lt;br /&gt;When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. (COM was designed around interfaces.) &lt;br /&gt;Use an abstract class to define a common base class for a family of types. &lt;br /&gt;Use an abstract class to provide default behavior. &lt;br /&gt;Subclass only a base class in a hierarchy to which the class logically belongs. &lt;br /&gt;Use an interface&lt;br /&gt;When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility. &lt;br /&gt;Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors. &lt;br /&gt;Use an interface to design a polymorphic hierarchy for value types. &lt;br /&gt;Use an interface when an immutable contract is really intended. &lt;br /&gt;A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality. &lt;br /&gt;Summary&lt;br /&gt;The following table compares the features of abstract classes and interfaces. &lt;br /&gt;&lt;br /&gt;Abstract class  Interface  &lt;br /&gt;Derived classes exhaust their single base class inheritance option.  Classes can implement multiple interfaces without using up their base class option. But, there are no default implementations.  &lt;br /&gt;Cannot be instantiated except as part of subclasses. Only derived classes can call an abstract class constructor.  Cannot be instantiated.  &lt;br /&gt;Defines abstract member signatures which derived classes must implement. Otherwise, the derived class itself will be abstract.  Defines abstract member signatures—all of which—implementing classes must implement. Otherwise, a compiler error results.  &lt;br /&gt;New non-abstract members may be added that derived classes will inherit without breaking version compatibility.  Extending an interface with new members breaks version compatibility.  &lt;br /&gt;Optionally, provide default (virtual) member implementation.  All members are virtual and cannot provide implementations.  &lt;br /&gt;Can include data fields.  Cannot include data fields. However, abstract properties may be declared.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-6002706548037411883?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/6002706548037411883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=6002706548037411883' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6002706548037411883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6002706548037411883'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2010/02/should-i-use-abstract-class-or.html' title='Should I use an abstract class or an interface?'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-7111835324748631482</id><published>2008-12-21T10:01:00.000-08:00</published><updated>2008-12-21T10:02:13.501-08:00</updated><title type='text'>Security in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Security is an indispensable aspect of every C# applications, and must be considered at every phase of development: not merely when design and implementation are complete. &lt;/p&gt; &lt;div id="ctl00_rs1_mainContentContainer_cpe85265" class="MTPS_CollapsibleRegion"&gt;    &lt;div id="ctl00_rs1_mainContentContainer_cpe85265_h" class="CollapseRegionLink"&gt;     &lt;img id="ctl00_rs1_mainContentContainer_cpe85265_i" class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width: 0px; vertical-align: middle;" /&gt; C# Specific Security Recommendations    &lt;/div&gt;&lt;div style="overflow: visible; display: block; height: auto; width: 673px;" id="ctl00_rs1_mainContentContainer_cpe85265_c" class="MTPS_CollapsibleSection"&gt;&lt;div style="display: block;" id="" class="MTPS_CollapsibleSection"&gt;     &lt;a name="sectionToggle0"&gt;&lt;/a&gt; &lt;p&gt;This list is in not an exhaustive list of potential security problems. It highlights some common issues of which C# developers need to be aware.&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;Use the &lt;a id="ctl00_rs1_mainContentContainer_ctl07" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe85265_c|ctl00_rs1_mainContentContainer_ctl07',this);" href="http://msdn.microsoft.com/en-us/library/74b4xzyw%28VS.80%29.aspx"&gt;checked&lt;/a&gt; keyword to control the overflow-checking context for integral-type arithmetic operations and conversions.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Always use the most restrictive data type for parameters. For example, when passing a value into a method that describes the size of a data structure, use unsigned integer rather than integer.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Do not make decisions based on filenames. Filenames can be expressed in many different ways, and your test for a particular file may be bypassed.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Never, ever hardcode passwords or other sensitive information into your application.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Always validate input that is used to generate SQL queries.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Validate all inputs into your methods. The regular expression methods in &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl08" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe85265_c|ctl00_rs1_mainContentContainer_ctl08',this);" href="http://msdn.microsoft.com/en-us/library/system.text.regularexpressions%28VS.80%29.aspx"&gt;System.Text.RegularExpressions&lt;/a&gt;&lt;/span&gt; namespace are useful for confirming input is of the correct form, such as an email address.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Don't display exception information: it provides any would-be attacker with valuable clues.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Ensure your application works while running with the least possible privileges. Few applications require a user to be logged in as an administrator.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Don't use your own encryption algorithms, use the &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl09" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe85265_c|ctl00_rs1_mainContentContainer_ctl09',this);" href="http://msdn.microsoft.com/en-us/library/system.security.cryptography%28VS.80%29.aspx"&gt;System.Security.Cryptography&lt;/a&gt;&lt;/span&gt; classes.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Give your Assemblies strong names.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Don't store sensitive information in XML or other configuration files.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Check managed code that wraps native code carefully. Confirm the native code is secure, especially with regard to buffer overruns.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Use caution when using delegates passed from outside your application.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Run &lt;a id="ctl00_rs1_mainContentContainer_ctl10" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe85265_c|ctl00_rs1_mainContentContainer_ctl10',this);" href="http://www.gotdotnet.com/team/fxcop/"&gt;FxCop&lt;/a&gt; on your assemblies to ensure compliance with Microsoft .NET Framework Design Guidelines. FxCop can also find and warn against over 200 code defects.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt;     &lt;/div&gt;&lt;/div&gt;   &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-7111835324748631482?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/7111835324748631482/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=7111835324748631482' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7111835324748631482'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/7111835324748631482'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/security-in-c.html' title='Security in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-317030885410744117</id><published>2008-12-21T10:00:00.000-08:00</published><updated>2008-12-21T10:01:08.933-08:00</updated><title type='text'>Reflection in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Reflection provides objects (of type &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/system.type%28VS.80%29.aspx"&gt;Type&lt;/a&gt;&lt;/span&gt;) that encapsulate assemblies, modules and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties. If you are using attributes in your code, Reflection enables you to access them. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/z0w1kczw%28VS.80%29.aspx"&gt;Attributes&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Here's a simple example of Reflection using the static method &lt;b&gt;GetType&lt;/b&gt; - inherited by all types from the &lt;b&gt;Object&lt;/b&gt; base class - to obtain the type of a variable:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl03_CSharp"&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl03CSharp" space="preserve"&gt;&lt;span style="color: green;"&gt;// Using GetType to obtain type information:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;int&lt;/span&gt; i = 42;&lt;br /&gt;System.Type type = i.GetType();&lt;br /&gt;System.Console.WriteLine(type);&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;The output is:&lt;/p&gt; &lt;p&gt; &lt;tt&gt;System.Int32&lt;/tt&gt; &lt;/p&gt; &lt;p&gt;In this example, Reflection is used to obtain the full name of a loaded assembly:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl04_CSharp"&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl04CSharp" space="preserve"&gt;&lt;span style="color: green;"&gt;// Using Reflection to get information from an Assembly:&lt;/span&gt;&lt;br /&gt;System.Reflection.Assembly o = System.Reflection.Assembly.Load(&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"mscorlib.dll"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;System.Console.WriteLine(o.GetName());&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;The output is:&lt;/p&gt; &lt;p&gt; &lt;tt&gt;mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&lt;/tt&gt; &lt;/p&gt; &lt;h1 class="heading"&gt;Reflection Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Reflection is useful in the following situations:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;When you need to access attributes in your program's metadata. See the topic &lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/z919e8tw%28VS.80%29.aspx"&gt;Accessing Attributes With Reflection&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;For examining and instantiating types in an assembly.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;For building new types at runtime. Use classes in &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl06" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl06',this);" href="http://msdn.microsoft.com/en-us/library/system.reflection.emit%28VS.80%29.aspx"&gt;System.Reflection.Emit&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;For performing late binding, accessing methods on types created at run time. See the topic &lt;a id="ctl00_rs1_mainContentContainer_ctl07" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl07',this);" href="http://msdn.microsoft.com/en-us/library/k3a58006%28VS.80%29.aspx"&gt;Dynamically Loading and Using Types&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-317030885410744117?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/317030885410744117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=317030885410744117' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/317030885410744117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/317030885410744117'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/reflection-in-c.html' title='Reflection in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-361204906684622727</id><published>2008-12-21T09:59:00.000-08:00</published><updated>2008-12-21T10:00:20.917-08:00</updated><title type='text'>Performance in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;This section covers two issues that can adversely effect performance, and links to resources on performance issues.&lt;/p&gt; &lt;h1 class="heading"&gt;Boxing and Unboxing&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Boxing and unboxing are computationally expensive processes. When a value type is boxed, an entirely new object must be created. This can take up to 20 times longer than an assignment. When unboxing, the casting process can take four times as long as an assignment. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/yz2be5wk%28VS.80%29.aspx"&gt;Boxing and Unboxing&lt;/a&gt;.&lt;/p&gt; &lt;/div&gt;&lt;h1 class="heading"&gt;Destructors&lt;/h1&gt;&lt;div id="sectionSection1" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Empty destructors should not be used. When a class contains a destructor, an entry is created in the Finalize queue. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this simply results in a loss of performance. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/66x5fx1b%28VS.80%29.aspx"&gt;Destructors&lt;/a&gt;.&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-361204906684622727?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/361204906684622727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=361204906684622727' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/361204906684622727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/361204906684622727'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/performance-in-c.html' title='Performance in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4558446604209587637</id><published>2008-12-21T09:58:00.000-08:00</published><updated>2008-12-21T09:59:03.954-08:00</updated><title type='text'>Threading  In C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Threading enables your C# program to perform concurrent processing so you can do more than one operation at a time. For example, you can use threading to monitor input from the user, perform background tasks, and handle simultaneous streams of input. The &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/system.threading%28VS.80%29.aspx"&gt;System.Threading&lt;/a&gt;&lt;/span&gt; namespace provides classes and interfaces that support multithreaded programming and enable you to easily perform tasks such as creating and starting new threads, synchronizing multiple threads, suspending threads, and aborting threads. &lt;/p&gt; &lt;p&gt;To incorporate threading in your C# code, simply create a function to be executed outside the main thread and point a new &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/system.threading.thread%28VS.80%29.aspx"&gt;Thread&lt;/a&gt;&lt;/span&gt; object at it. The following code example creates a new thread in a C# application&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl03_CSharp"&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl03CSharp" space="preserve"&gt;System.Threading.Thread newThread;&lt;br /&gt;newThread = &lt;span style="color: blue;"&gt;new&lt;/span&gt; System.Threading.Thread(anObject.AMethod);&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;The following code example starts a new thread in a C# application:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl04_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;div class="CopyCodeButton"&gt;&lt;a class="copyCode" href="javascript:CopyCode('ctl00_rs1_mainContentContainer_ctl04CSharp');"&gt;&lt;img class="LibC_copy_off" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" align="middle" border="0" height="9" /&gt; Copy Code&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl04CSharp" space="preserve"&gt;newThread.Start();&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Multithreading solves problems with responsiveness and multi-tasking, but can also introduce resource sharing and synchronization issues because threads are interrupted and resumed without warning according to a central thread scheduling mechanism. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/ms173179%28VS.80%29.aspx"&gt;Thread Synchronization&lt;/a&gt;. See &lt;a id="ctl00_rs1_mainContentContainer_ctl06" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl06',this);" href="http://msdn.microsoft.com/en-us/library/e1dx6b2h%28VS.80%29.aspx"&gt;Using Threads and Threading&lt;/a&gt; for overview information.&lt;/p&gt; &lt;div id="ctl00_rs1_mainContentContainer_cpe85047" class="MTPS_CollapsibleRegion"&gt;    &lt;div id="ctl00_rs1_mainContentContainer_cpe85047_h" class="CollapseRegionLink"&gt;     &lt;img id="ctl00_rs1_mainContentContainer_cpe85047_i" class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width: 0px; vertical-align: middle;" /&gt; Overview    &lt;/div&gt;&lt;div style="overflow: visible; display: block; height: auto; width: 673px;" id="ctl00_rs1_mainContentContainer_cpe85047_c" class="MTPS_CollapsibleSection"&gt;&lt;div style="display: block;" id="" class="MTPS_CollapsibleSection"&gt;     &lt;a name="sectionToggle0"&gt;&lt;/a&gt; &lt;p&gt;Threads have the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;Threads enable your C# program to perform concurrent processing.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;The .NET Framework's &lt;b&gt;System.Threading&lt;/b&gt; namespace makes using threads easier.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Threads share the application's resources. For more information, see &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl10" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe85047_c|ctl00_rs1_mainContentContainer_ctl10',this);" href="http://msdn.microsoft.com/en-us/library/e1dx6b2h%28VS.80%29.aspx"&gt;Using Threads and Threading&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt;     &lt;/div&gt;&lt;/div&gt;   &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4558446604209587637?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4558446604209587637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4558446604209587637' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4558446604209587637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4558446604209587637'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/threading-in-c.html' title='Threading  In C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1773573571444817373</id><published>2008-12-21T09:57:00.000-08:00</published><updated>2008-12-21T09:58:05.048-08:00</updated><title type='text'>Interoperability in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Interoperability enables you to preserve and leverage existing investments in unmanaged code. Code running under the control of the common language runtime (CLR) is called "managed code", and code running outside the CLR is "unmanaged code". COM, COM+, C++ components, ActiveX components, and Win32 API are examples of unmanaged code.&lt;/p&gt; &lt;p&gt;The .NET Framework enables interoperability with unmanaged code through platform invoke services, the &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices%28VS.80%29.aspx"&gt;System.Runtime.InteropServices&lt;/a&gt;&lt;/span&gt; namespace, and the CLR and through COM Interoperability (COM interop). &lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;There are two ways to use unmanaged APIs from managed code: through platform invoke and through It Just Works (IJW) in C++. Platform invoke enables managed code to call functions exported from an unmanaged dynamic link library (DLL), such as Win32 API and custom DLLs. The CLR handles DLL loading and parameter marshaling. For performance, check if there is an equivalent function available in the .NET Framework rather than using platform invoke. For more information, see &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/0h9e9t7d%28VS.80%29.aspx"&gt;A Closer Look at Platform Invoke&lt;/a&gt;&lt;/span&gt;. &lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;COM interop, which enables managed code to interact with COM objects through COM interfaces and COM clients. There are two ways to use COM components from managed code: &lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;For calling OLE Automation compatible COM components, use COM interop or tlbimp.exe. The CLR handles COM component activation and parameter marshaling. &lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;For IDL based COM components, use IJW and C++. Every public managed class that implements &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.unmanagedtype.iunknown%28VS.80%29.aspx"&gt;IUnknown&lt;/a&gt;&lt;/span&gt;, &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.unmanagedtype.idispatch%28VS.80%29.aspx"&gt;IDispatch&lt;/a&gt;&lt;/span&gt;, and other standard COM interfaces can be called from unmanaged code through COM interop. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/asp.net/using/understanding/interop/default.aspx?pull=/library/en-us/dnbda/html/cominterop.asp"&gt;Microsoft .NET/COM Migration and Interoperability&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;For more information, see &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl06" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl06',this);" href="http://msdn.microsoft.com/en-us/library/sd10k43k%28VS.80%29.aspx"&gt;Interoperating with Unmanaged Code&lt;/a&gt;&lt;/span&gt; and &lt;a id="ctl00_rs1_mainContentContainer_ctl07" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl07',this);" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scalenetchapt07.asp"&gt;Improving Interop Performance&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Both PInvoke and COM interop use marshaling to translate arguments such as integers, strings, arrays, structures, and pointers between managed and unmanaged code. For more information, see &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl08" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl08',this);" href="http://msdn.microsoft.com/en-us/library/eaw10et3%28VS.80%29.aspx"&gt;Interop Marshaling Overview&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1773573571444817373?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1773573571444817373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1773573571444817373' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1773573571444817373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1773573571444817373'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/interoperability-in-c.html' title='Interoperability in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-8499037319335920699</id><published>2008-12-21T09:56:00.000-08:00</published><updated>2008-12-21T09:57:22.930-08:00</updated><title type='text'>Exceptions and Exception Handling  in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;The C# language's exception handling features provide a way to deal with any unexpected or exceptional situations that arise while a program is running. Exception handling uses the &lt;b&gt;try&lt;/b&gt;, &lt;b&gt;catch&lt;/b&gt;, and &lt;b&gt;finally&lt;/b&gt; keywords to attempt actions that may not succeed, to handle failures, and to clean up resources afterwards. Exceptions can be generated by the common language runtime (CLR), by third-party libraries, or by the application code using the &lt;b&gt;throw&lt;/b&gt; keyword.&lt;/p&gt; &lt;p&gt;In this example, a method tests for a division by zero, and catches the error. Without the exception handling, this program would terminate with a &lt;b&gt;DivideByZeroException was unhandled&lt;/b&gt; error.&lt;/p&gt; &lt;div class="" id="ctl00_rs1_mainContentContainer_ctl01_other"&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl01other" space="preserve"&gt;int SafeDivision(int x, int y)&lt;br /&gt;{&lt;br /&gt;   try&lt;br /&gt;   {&lt;br /&gt;       return (x / y);&lt;br /&gt;   }&lt;br /&gt;   catch (System.DivideByZeroException dbz)&lt;br /&gt;   {&lt;br /&gt;       System.Console.WriteLine("Division by zero attempted!");&lt;br /&gt;       return 0;&lt;br /&gt;   }&lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div id="ctl00_rs1_mainContentContainer_cpe84765" class="MTPS_CollapsibleRegion"&gt;    &lt;div id="ctl00_rs1_mainContentContainer_cpe84765_h" class="CollapseRegionLink"&gt;     &lt;img id="ctl00_rs1_mainContentContainer_cpe84765_i" class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width: 0px; vertical-align: middle;" /&gt; Exceptions Overview    &lt;/div&gt;&lt;div style="overflow: visible; display: block; height: auto; width: 673px;" id="ctl00_rs1_mainContentContainer_cpe84765_c" class="MTPS_CollapsibleSection"&gt;&lt;div style="display: block;" id="" class="MTPS_CollapsibleSection"&gt;     &lt;a name="sectionToggle0"&gt;&lt;/a&gt; &lt;p&gt;Exceptions have the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;When your application encounters an exceptional circumstance, such as a division by zero or low memory warning, an exception is generated.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Use a &lt;b&gt;try&lt;/b&gt; block around the statements that might throw exceptions.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Once an exception occurs within the &lt;b&gt;try&lt;/b&gt; block, the flow of control immediately jumps to an associated exception handler, if one is present.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;If no exception handler for a given exception is present, the program stops executing with an error message.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;If a catch block defines an exception variable, you can use it to get more information on the type of exception that occurred.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Actions that may result in an exception are executed with the &lt;b&gt;try&lt;/b&gt; keyword.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;An exception handler is a block of code that is executed when an exception occurs. In C#, the &lt;b&gt;catch&lt;/b&gt; keyword is used to define an exception handler.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Exceptions can be explicitly generated by a program using the &lt;b&gt;throw&lt;/b&gt; keyword.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Exception objects contain detailed information about the error, including the state of the call stack and a text description of the error.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Code in a &lt;b&gt;finally&lt;/b&gt; block is executed even if an exception is thrown, thus allowing a program to release resources.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt;     &lt;/div&gt;&lt;/div&gt;   &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-8499037319335920699?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/8499037319335920699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=8499037319335920699' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8499037319335920699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8499037319335920699'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/exceptions-and-exception-handling-in-c.html' title='Exceptions and Exception Handling  in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1939764328557661094</id><published>2008-12-21T09:55:00.002-08:00</published><updated>2008-12-21T09:56:27.114-08:00</updated><title type='text'>Collection Classes in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;The .NET Framework provides specialized classes for data storage and retrieval. These classes provide support for stacks, queues, lists, and hash tables. Most collection classes implement the same interfaces, and these interfaces may be inherited to create new collection classes that fit more specialized data storage needs.&lt;/p&gt; &lt;div class="alert"&gt;&lt;table width="100%"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left"&gt;&lt;img class="note" alt="Note" src="http://i.msdn.microsoft.com/ybcx56wz.note%28en-US,VS.80%29.gif" /&gt;Note &lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; &lt;p&gt;Applications that target version 2.0 and later of the .NET Framework should use the generic collection classes in the &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/system.collections.generic%28VS.80%29.aspx"&gt;System.Collections.Generic&lt;/a&gt;&lt;/span&gt; namespace, which provide greater type-safety and efficiency than their non-generic counterparts.&lt;/p&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl02_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl02CSharp" space="preserve"&gt;ArrayList list = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ArrayList();&lt;br /&gt;list.Add(10);&lt;br /&gt;list.Add(20);&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 class="heading"&gt;Collection Classes Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Collection Classes have the following properties&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;Collection classes are defined as part of the &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/system.collections%28VS.80%29.aspx"&gt;System.Collections&lt;/a&gt;&lt;/span&gt; or &lt;b&gt;System.Collections.Generic&lt;/b&gt; namespace. &lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Most collection classes derive from the interfaces &lt;b&gt;ICollection&lt;/b&gt;, &lt;b&gt;IComparer&lt;/b&gt;, &lt;b&gt;IEnumerable&lt;/b&gt;, &lt;b&gt;IList&lt;/b&gt;, &lt;b&gt;IDictionary&lt;/b&gt;, and &lt;b&gt;IDictionaryEnumerator&lt;/b&gt; and their generic equivalents.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Using generic collection classes provides increased type-safety and in some cases can provide better performance, especially when storing value types. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/b5bx6xee%28VS.80%29.aspx"&gt;Benefits of Generics&lt;/a&gt;. &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1939764328557661094?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1939764328557661094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1939764328557661094' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1939764328557661094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1939764328557661094'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/collection-classes-in-c.html' title='Collection Classes in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-841157680438938363</id><published>2008-12-21T09:55:00.001-08:00</published><updated>2008-12-21T09:55:29.697-08:00</updated><title type='text'>Attributes in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Attributes provide a powerful method of associating declarative information with C# code (types, methods, properties, and so forth). Once associated with a program entity, the attribute can be queried at run time using a technique called &lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/ms173183%28VS.80%29.aspx"&gt;Reflection&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Attributes exist in two forms: attributes that are defined in the Common Language Runtime's base class library and custom attributes that you can create, to add extra information to your code. This information can later be retrieved programmatically.&lt;/p&gt; &lt;p&gt;In this example, the attribute &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/system.reflection.typeattributes.serializable%28VS.80%29.aspx"&gt;System.Reflection.TypeAttributes.Serializable&lt;/a&gt;&lt;/span&gt; is used to apply a specific characteristic to a class:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl03_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl03CSharp" space="preserve"&gt;[System.Serializable]&lt;br /&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; SampleClass&lt;br /&gt;{&lt;br /&gt;   &lt;span style="color: green;"&gt;// Objects of this type can be serialized.&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 class="heading"&gt;Attribute Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Attributes have the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;Attributes add metadata to your program. Metadata is information embedded in your program such as compiler instructions or descriptions of data.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Your program can examine its own metadata using &lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/ms173183%28VS.80%29.aspx"&gt;Reflection&lt;/a&gt;. See &lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/z919e8tw%28VS.80%29.aspx"&gt;Accessing Attributes With Reflection&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Attributes are commonly used when interacting with COM.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-841157680438938363?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/841157680438938363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=841157680438938363' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/841157680438938363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/841157680438938363'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/attributes-in-c.html' title='Attributes in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-6133068204837161316</id><published>2008-12-21T09:53:00.002-08:00</published><updated>2008-12-21T09:54:43.702-08:00</updated><title type='text'>Assemblies and the Global Assembly Cache in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;An assembly is a fundamental building block of any .NET Framework application. For example, when you build a simple C# application, Visual Studio creates an assembly in the form of a single portable executable (PE) file, specifically an EXE or DLL.&lt;/p&gt; &lt;p&gt;Assemblies contain metadata that describe their own internal version number and details of all the data and object types they contain. For more information see &lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/1w45z383%28VS.80%29.aspx"&gt;Assembly Manifest&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Assemblies are only loaded as they are required. If they are not used, they are not loaded. This means that assemblies can be an efficient way to manage resources in larger projects.&lt;/p&gt; &lt;p&gt;Assemblies can contain one or more modules. For example, larger projects may be planned in such a way that several individual developers work on separate modules, all coming together to create a single assembly. For more information on modules, see the topic &lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/226t7yxe%28VS.80%29.aspx"&gt;How to: Build a Multifile Assembly&lt;/a&gt;.&lt;/p&gt; &lt;h1 class="heading"&gt;Assemblies Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Assemblies have the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;Assemblies are implemented as .exe or .dll files.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;You can share an assembly between applications by placing it in the Global Assembly Cache.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Assemblies must be strong-named before they can be placed in the Global Assembly Cache. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/wd40t7ad%28VS.80%29.aspx"&gt;Strong-Named Assemblies&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Assemblies are only loaded into memory if they are required.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;You can programmatically obtain information about an assembly using reflection. For more information, see the topic &lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/ms173183%28VS.80%29.aspx"&gt;Reflection&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;If you want to load an assembly only to inspect it, use a method such as &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.reflectiononlyloadfrom%28VS.80%29.aspx"&gt;ReflectionOnlyLoadFrom&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;You can use two versions of the same assembly in a single application. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl06" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl06',this);" href="http://msdn.microsoft.com/en-us/library/ms173212%28VS.80%29.aspx"&gt;extern alias&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-6133068204837161316?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/6133068204837161316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=6133068204837161316' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6133068204837161316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/6133068204837161316'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/assemblies-and-global-assembly-cache-in.html' title='Assemblies and the Global Assembly Cache in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-935157935564079221</id><published>2008-12-21T09:53:00.001-08:00</published><updated>2008-12-21T09:53:42.052-08:00</updated><title type='text'>Application Domains in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Application domains provide a flexible and secure method of isolating running applications.&lt;/p&gt; &lt;p&gt;Application domains are usually created and manipulated by run-time hosts. Occasionally, you may want your application to programmatically interact with your application domains, for example, to unload a component without having to stop your application from running.&lt;/p&gt; &lt;p&gt;Application domains aid security, separating applications from each other and each other's data. A single process can run several application domains, with the same level of isolation that would exist in separate processes. Running multiple applications within a single process increases server scalability.&lt;/p&gt; &lt;p&gt;In the following code example, you create a new application domain and then load and execute a previously built assembly, &lt;tt&gt;HelloWorld.exe&lt;/tt&gt;, that is stored on drive C.&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl01_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl01CSharp" space="preserve"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main()&lt;br /&gt;{&lt;br /&gt;   &lt;span style="color: green;"&gt;// Create an Application Domain:&lt;/span&gt;&lt;br /&gt;   System.AppDomain newDomain = System.AppDomain.CreateDomain(&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"NewApplicationDomain"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: green;"&gt;// Load and execute an assembly:&lt;/span&gt;&lt;br /&gt;   newDomain.ExecuteAssembly(@&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"c:\HelloWorld.exe"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: green;"&gt;// Unload the application domain:&lt;/span&gt;&lt;br /&gt;   System.AppDomain.Unload(newDomain);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div id="ctl00_rs1_mainContentContainer_cpe83733" class="MTPS_CollapsibleRegion"&gt;    &lt;div id="ctl00_rs1_mainContentContainer_cpe83733_h" class="CollapseRegionLink"&gt;     &lt;img id="ctl00_rs1_mainContentContainer_cpe83733_i" class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-width: 0px; vertical-align: middle;" /&gt; Application Domains Overview    &lt;/div&gt;&lt;div style="overflow: visible; display: block; height: auto; width: 673px;" id="ctl00_rs1_mainContentContainer_cpe83733_c" class="MTPS_CollapsibleSection"&gt;&lt;div style="display: block;" id="" class="MTPS_CollapsibleSection"&gt;     &lt;a name="sectionToggle0"&gt;&lt;/a&gt; &lt;p&gt;Application domains have the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;An assembly must be loaded into an application domain before it can be executed. For more information, see &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_cpe83733_c|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/ms173099%28VS.80%29.aspx"&gt;Assemblies and the Global Assembly Cache (C# Programming Guide)&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Faults in one application domain cannot affect other code running in another application domain.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Individual applications can be stopped and code unloaded without stopping the entire process. You cannot unload individual assemblies or types, only entire application domains.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt;     &lt;/div&gt;&lt;/div&gt;   &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-935157935564079221?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/935157935564079221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=935157935564079221' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/935157935564079221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/935157935564079221'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/application-domains-in-c.html' title='Application Domains in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1840060664267950889</id><published>2008-12-21T09:51:00.000-08:00</published><updated>2008-12-21T09:52:41.205-08:00</updated><title type='text'>XML Documentation Comments in C#</title><content type='html'>&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;In Visual C# you can create documentation for your code by including XML tags in special comment fields in your source code directly before the code block they refer to. For example:&lt;/p&gt; &lt;div class="" id="ctl00_rs1_mainContentContainer_ctl01_other"&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl01other" space="preserve"&gt;/// &lt;summary&gt;&lt;br /&gt;///  This class performs an important function.&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;public class MyClass{}&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;When you compile with &lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/3260k4x7%28VS.80%29.aspx"&gt;/doc&lt;/a&gt; the compiler will search for all XML tags in your source code and create an XML documentation file.&lt;/p&gt; &lt;table width="100%"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left"&gt;&lt;img class="note" alt="Note" src="http://i.msdn.microsoft.com/b2s063f7.note%28en-US,VS.80%29.gif" /&gt;Note &lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; &lt;p&gt;The XML doc comments are not metadata; they are not included in the compiled assembly and therefore they are not accessible through reflection.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1840060664267950889?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1840060664267950889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1840060664267950889' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1840060664267950889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1840060664267950889'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/xml-documentation-comments-in-c.html' title='XML Documentation Comments in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4802382876170675078</id><published>2008-12-13T23:42:00.001-08:00</published><updated>2008-12-13T23:42:41.072-08:00</updated><title type='text'>Unsafe Code and Pointers  in C#</title><content type='html'>&lt;div class="title"&gt;Unsafe Code and Pointers &lt;!----&gt;&lt;/div&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;To maintain type safety and security, by default C# does not support pointer arithmetic. However, by using the &lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/chfa2zb8%28VS.80%29.aspx"&gt;unsafe&lt;/a&gt; keyword, it is possible to define an unsafe context in which pointers can be used. For more information about pointers, see the topic &lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/y31yhkeb%28VS.80%29.aspx"&gt;Pointer types&lt;/a&gt;. &lt;/p&gt; &lt;div class="alert"&gt;&lt;table width="100%"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th align="left"&gt;&lt;img class="note" alt="Note" src="http://i.msdn.microsoft.com/t2yzs44b.note%28en-US,VS.80%29.gif" /&gt;Note &lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt; &lt;p&gt;In the common language runtime (CLR), unsafe code is referred to as unverifiable code. Unsafe code in C# is not necessarily dangerous; it is simply code whose safety cannot be verified by the CLR. The CLR will therefore only execute unsafe code if it is within a fully trusted assembly. If you use unsafe code, it is your responsibility to ensure that your code does not introduce security risks or pointer errors. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/ms173195%28VS.80%29.aspx"&gt;Security and C#&lt;/a&gt;.&lt;/p&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt; &lt;h1 class="heading"&gt;Unsafe Code Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Unsafe code has the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;Methods, types, and code blocks can be defined as unsafe.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;In some cases, unsafe code may increase an application's performance by removing array bounds checks.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Unsafe code is required when calling native functions that require pointers.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Using unsafe code introduces security and stability risks.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;In order for C# to compile unsafe code, the application must be compiled with &lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/ct597kb0%28VS.80%29.aspx"&gt;/unsafe&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4802382876170675078?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4802382876170675078/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4802382876170675078' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4802382876170675078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4802382876170675078'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/unsafe-code-and-pointers-in-c.html' title='Unsafe Code and Pointers  in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-676362447028223615</id><published>2008-12-13T23:37:00.000-08:00</published><updated>2008-12-13T23:39:23.574-08:00</updated><title type='text'>Nullable Types in C#</title><content type='html'>Nullable Types&lt;br /&gt;&lt;br /&gt;Nullable types are instances of the System.Nullable struct. A nullable type can represent the normal range of values for its underlying value type, plus an additional null value. For example, a Nullable&lt;int32&gt;, pronounced "Nullable of Int32," can be assigned any value from -2147483648 to 2147483647, or it can be assigned the null value. A Nullable&lt;bool&gt; can be assigned the values true or false, or null. The ability to assign null to numeric and Boolean types is particularly useful when dealing with databases and other data types containing elements that may not be assigned a value. For example, a Boolean field in a database can store the values true or false, or it may be undefined.&lt;br /&gt;C#&lt;br /&gt;Copy Code&lt;br /&gt;&lt;br /&gt;class NullableExample&lt;br /&gt;{&lt;br /&gt;   static void Main()&lt;br /&gt;   {&lt;br /&gt;       int? num = null;&lt;br /&gt;       if (num.HasValue == true)&lt;br /&gt;       {&lt;br /&gt;           System.Console.WriteLine("num = " + num.Value);&lt;br /&gt;       }&lt;br /&gt;       else&lt;br /&gt;       {&lt;br /&gt;           System.Console.WriteLine("num = Null");&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       //y is set to zero&lt;br /&gt;       int y = num.GetValueOrDefault();&lt;br /&gt;&lt;br /&gt;       // num.Value throws an InvalidOperationException if num.HasValue is false&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;           y = num.Value;&lt;br /&gt;       }&lt;br /&gt;       catch (System.InvalidOperationException e)&lt;br /&gt;       {&lt;br /&gt;           System.Console.WriteLine(e.Message);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The above will display the output:&lt;br /&gt;&lt;br /&gt;num = Null&lt;br /&gt;&lt;br /&gt;Nullable object must have a value.&lt;br /&gt;Nullable Types Overview&lt;br /&gt;&lt;br /&gt;Nullable types have the following characteristics:&lt;br /&gt;&lt;br /&gt;   *&lt;br /&gt;&lt;br /&gt;     Nullable types represent value-type variables that can be assigned the value of null. You cannot create a nullable type based on a reference type. (Reference types already support the null value.)&lt;br /&gt;   *&lt;br /&gt;&lt;br /&gt;     The syntax T? is shorthand for System.Nullable&lt;t&gt;, where T is a value type. The two forms are interchangeable.&lt;br /&gt;   *&lt;br /&gt;&lt;br /&gt;     Assign a value to a nullable type in the same way as for an ordinary value type, for example int? x = 10; or double? d = 4.108;&lt;br /&gt;   *&lt;br /&gt;&lt;br /&gt;     Use the System.Nullable.GetValueOrDefault property to return either the assigned value, or the default value for the underlying type if the value is null, for example int j = x.GetValueOrDefault();&lt;br /&gt;   *&lt;br /&gt;&lt;br /&gt;     Use the HasValue and Value read-only properties to test for null and retrieve the value, for example if(x.HasValue) j = x.Value;&lt;br /&gt;         o&lt;br /&gt;&lt;br /&gt;           The HasValue property returns true if the variable contains a value, or false if it is null.&lt;br /&gt;         o&lt;br /&gt;&lt;br /&gt;           The Value property returns a value if one is assigned, otherwise a System.InvalidOperationException is thrown.&lt;br /&gt;         o&lt;br /&gt;&lt;br /&gt;           The default value for a nullable type variable sets HasValue to false. The Value is undefined.&lt;br /&gt;   *&lt;br /&gt;&lt;br /&gt;     Use the ?? operator to assign a default value that will be applied when a nullable type whose current value is null is assigned to a non-nullable type, for example int? x = null; int y = x ?? -1;&lt;br /&gt;&lt;/t&gt;&lt;/bool&gt;&lt;/int32&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-676362447028223615?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/676362447028223615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=676362447028223615' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/676362447028223615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/676362447028223615'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/nullable-types-in-c.html' title='Nullable Types in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-3681030923023997556</id><published>2008-12-13T23:33:00.001-08:00</published><updated>2008-12-13T23:33:31.538-08:00</updated><title type='text'>Namespaces in C#</title><content type='html'>&lt;div class="title"&gt;Namespaces&lt;!----&gt;&lt;/div&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Namespaces are heavily used in C# programming in two ways. First, the .NET Framework uses namespaces to organize its many classes, as follows:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl01_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;div class="CopyCodeButton"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl01CSharp" space="preserve"&gt;System.Console.WriteLine(&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Hello World!"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt; &lt;b&gt;System&lt;/b&gt; is a namespace and &lt;b&gt;Console&lt;/b&gt; is a class contained within that namespace. The &lt;b&gt;using&lt;/b&gt; keyword can be used so that the entire name is not required, like this:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl02_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;div class="CopyCodeButton"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl02CSharp" space="preserve"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl03_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;div class="CopyCodeButton"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl03CSharp" space="preserve"&gt;Console.WriteLine(&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Hello"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;Console.WriteLine(&lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"World!"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;For more information, see the topic &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/sf0df423%28VS.80%29.aspx"&gt;using Directive (C# Reference)&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt; &lt;p&gt;Second, declaring your own namespaces can help you control the scope of class and method names in larger programming projects. Use the &lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/z2kcy19k%28VS.80%29.aspx"&gt;namespace&lt;/a&gt; keyword to declare a namespace, as in the following example:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl06_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;div class="CopyCodeButton"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl06CSharp" space="preserve"&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; SampleNamespace&lt;br /&gt;{&lt;br /&gt;   &lt;span style="color: blue;"&gt;class&lt;/span&gt; SampleClass&lt;br /&gt;   {&lt;br /&gt;       &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; SampleMethod()&lt;br /&gt;       {&lt;br /&gt;           System.Console.WriteLine(&lt;br /&gt;             &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"SampleMethod inside SampleNamespace"&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 class="heading"&gt;Namespaces Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;A namespace has the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;They organize large code projects.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;They are delimited with the &lt;b&gt;.&lt;/b&gt; operator.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;The &lt;b&gt;using directive&lt;/b&gt; means you do not need to specify the name of the namespace for every class.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;The &lt;b&gt;global&lt;/b&gt; namespace is the "root" namespace: &lt;b&gt;global::system&lt;/b&gt; will always refer to the .NET Framework namespace &lt;b&gt;System&lt;/b&gt;.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-3681030923023997556?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/3681030923023997556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=3681030923023997556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3681030923023997556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/3681030923023997556'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/namespaces-in-c.html' title='Namespaces in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-1418036889035349506</id><published>2008-12-13T23:32:00.001-08:00</published><updated>2008-12-13T23:32:35.889-08:00</updated><title type='text'>Iterators in C#</title><content type='html'>&lt;div class="title"&gt;Iterators&lt;!----&gt;&lt;/div&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Iterators are a new feature in C# 2.0. An iterator is a method, &lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/ms228503%28VS.80%29.aspx"&gt;get&lt;/a&gt; accessor or operator that enables you to support &lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/ttw7t8t6%28VS.80%29.aspx"&gt;foreach&lt;/a&gt; iteration in a &lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/0b0thckt%28VS.80%29.aspx"&gt;class&lt;/a&gt; or &lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/ah19swz4%28VS.80%29.aspx"&gt;struct&lt;/a&gt; without having to implement the entire &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/system.collections.ienumerable%28VS.80%29.aspx"&gt;IEnumerable&lt;/a&gt;&lt;/span&gt; interface. Instead, you provide just an iterator, which simply traverses the data structures in your class. When the compiler detects your iterator, it will automatically generate the &lt;tt&gt;Current&lt;/tt&gt;, &lt;tt&gt;MoveNext&lt;/tt&gt; and &lt;tt&gt;Dispose&lt;/tt&gt; methods of the &lt;b&gt;IEnumerable&lt;/b&gt; or &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl06" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl06',this);" href="http://msdn.microsoft.com/en-us/library/9eekhta0%28VS.80%29.aspx"&gt;IEnumerable&lt;/a&gt;&lt;/span&gt;&lt;t&gt; interface. &lt;/p&gt; &lt;h1 class="heading"&gt;Iterators Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;An iterator is a section of code that returns an ordered sequence of values of the same type.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;An iterator can be used as the body of a method, an operator, or a &lt;b&gt;get&lt;/b&gt; accessor.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;The iterator code uses the &lt;b&gt;yield return&lt;/b&gt; statement to return each element in turn. &lt;b&gt;yield break&lt;/b&gt; ends the iteration. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl07" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl07',this);" href="http://msdn.microsoft.com/en-us/library/9k7k7cf0%28VS.80%29.aspx"&gt;yield&lt;/a&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Multiple iterators can be implemented on a class. Each iterator must have a unique name just like any class member, and can be invoked by client code in a &lt;b&gt;foreach&lt;/b&gt; statement as follows: &lt;tt&gt;foreach(int x in SampleClass.Iterator2){}&lt;/tt&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;The return type of an iterator must be &lt;b&gt;IEnumerable&lt;/b&gt;, &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl08" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl08',this);" href="http://msdn.microsoft.com/en-us/library/system.collections.ienumerator%28VS.80%29.aspx"&gt;IEnumerator&lt;/a&gt;&lt;/span&gt;, &lt;b&gt;IEnumerable&lt;/b&gt;&lt;t&gt;, or &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl09" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl09',this);" href="http://msdn.microsoft.com/en-us/library/78dfe2yb%28VS.80%29.aspx"&gt;IEnumerator&lt;/a&gt;&lt;/span&gt;&lt;t&gt;.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The &lt;a id="ctl00_rs1_mainContentContainer_ctl10" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl10',this);" href="http://msdn.microsoft.com/en-us/library/9k7k7cf0%28VS.80%29.aspx"&gt;yield&lt;/a&gt; keyword is used to specify the value, or values, returned. When the &lt;b&gt;yield return&lt;/b&gt; statement is reached, the current location is stored. Execution is restarted from this location the next time the iterator is called.&lt;/p&gt; &lt;p&gt;Iterators are especially useful with collection classes, providing an easy way to iterate non-trivial data structures such as binary trees.&lt;/p&gt; &lt;/div&gt;&lt;h1 class="heading"&gt;Related Sections&lt;/h1&gt;&lt;div id="sectionSection1" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;For more information:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt; &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl11" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl11',this);" href="http://msdn.microsoft.com/en-us/library/65zzykke%28VS.80%29.aspx"&gt;Using Iterators (C# Programming Guide)&lt;/a&gt;&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt; &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl12" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl12',this);" href="http://msdn.microsoft.com/en-us/library/8b1xzat2%28VS.80%29.aspx"&gt;How to: Create an Iterator Block for a List of Integers (C# Programming Guide)&lt;/a&gt;&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt; &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl13" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl13',this);" href="http://msdn.microsoft.com/en-us/library/ee5kxzk0%28VS.80%29.aspx"&gt;How to: Create an Iterator Block for a Generic List (C# Programming Guide)&lt;/a&gt;&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt; &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl14" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl14',this);" href="http://msdn.microsoft.com/en-us/library/kwtft8ak%28VS.80%29.aspx"&gt;Generic Interfaces (C# Programming Guide)&lt;/a&gt;&lt;/span&gt; &lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;h1 class="heading"&gt;Example&lt;/h1&gt;&lt;div id="sectionSection2" class="seeAlsoNoToggleSection"&gt;  &lt;div class="subSection"&gt; &lt;p&gt;In this example, the class &lt;tt&gt;DaysOfTheWeek&lt;/tt&gt; is a simple collection class that stores the days of the week as strings. After each iteration of a &lt;b&gt;foreach&lt;/b&gt; loop, the next string in the collection is returned.&lt;/p&gt; &lt;/div&gt; &lt;div class="subSection"&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl15_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;div class="CopyCodeButton"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl15CSharp" space="preserve"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; DaysOfTheWeek : System.Collections.IEnumerable&lt;br /&gt;{&lt;br /&gt;   &lt;span style="color: blue;"&gt;string&lt;/span&gt;[] m_Days = { &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Sun"&lt;/span&gt;&lt;/span&gt;, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Mon"&lt;/span&gt;&lt;/span&gt;, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Tue"&lt;/span&gt;&lt;/span&gt;, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Wed"&lt;/span&gt;&lt;/span&gt;, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Thr"&lt;/span&gt;&lt;/span&gt;, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Fri"&lt;/span&gt;&lt;/span&gt;, &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;"Sat"&lt;/span&gt;&lt;/span&gt; };&lt;br /&gt;&lt;br /&gt;   &lt;span style="color: blue;"&gt;public&lt;/span&gt; System.Collections.IEnumerator GetEnumerator()&lt;br /&gt;   {&lt;br /&gt;       &lt;span style="color: blue;"&gt;for&lt;/span&gt; (&lt;span style="color: blue;"&gt;int&lt;/span&gt; i = 0; i &lt; m_Days.Length; i++)&lt;br /&gt;       {&lt;br /&gt;           yield &lt;span style="color: blue;"&gt;return&lt;/span&gt; m_Days[i];&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; TestDaysOfTheWeek&lt;br /&gt;{&lt;br /&gt;   &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main()&lt;br /&gt;   {&lt;br /&gt;       &lt;span style="color: green;"&gt;// Create an instance of the collection class&lt;/span&gt;&lt;br /&gt;       DaysOfTheWeek week = &lt;span style="color: blue;"&gt;new&lt;/span&gt; DaysOfTheWeek();&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: green;"&gt;// Iterate with foreach&lt;/span&gt;&lt;br /&gt;       &lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: blue;"&gt;string&lt;/span&gt; day &lt;span style="color: blue;"&gt;in&lt;/span&gt; week)&lt;br /&gt;       {&lt;br /&gt;           System.Console.Write(day + &lt;span style="color: maroon;"&gt;&lt;span style="color: maroon;"&gt;" "&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;h1 class="heading"&gt;Output&lt;/h1&gt;&lt;div id="sectionSection3" class="seeAlsoNoToggleSection"&gt; &lt;pre&gt;Sun Mon Tue Wed Thr Fri Sat&lt;/pre&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-1418036889035349506?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/1418036889035349506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=1418036889035349506' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1418036889035349506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/1418036889035349506'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/iterators-in-c.html' title='Iterators in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-8869953545073628373</id><published>2008-12-13T23:31:00.001-08:00</published><updated>2008-12-13T23:31:47.802-08:00</updated><title type='text'>Generics  in C#</title><content type='html'>&lt;div class="title"&gt;Generics &lt;!----&gt;&lt;/div&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Generics are a new feature in version 2.0 of the C# language and the common language runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code. For example, by using a generic type parameter T you can write a single class that other client code can use without incurring the cost or risk of runtime casts or boxing operations, as shown here:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl01_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;div class="CopyCodeButton"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl01CSharp" space="preserve"&gt;&lt;span style="color: green;"&gt;// Declare the generic class&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; GenericList&lt;t&gt;&lt;br /&gt;{&lt;br /&gt;   &lt;span style="color: blue;"&gt;void&lt;/span&gt; Add(T input) { }&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; TestGenericList&lt;br /&gt;{&lt;br /&gt;   &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; ExampleClass { }&lt;br /&gt;   &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main()&lt;br /&gt;   {&lt;br /&gt;       &lt;span style="color: green;"&gt;// Declare a list of type int&lt;/span&gt;&lt;br /&gt;       GenericList&lt;&lt;span style="color: blue;"&gt;int&lt;/span&gt;&gt; list1 = &lt;span style="color: blue;"&gt;new&lt;/span&gt; GenericList&lt;&lt;span style="color: blue;"&gt;int&lt;/span&gt;&gt;();&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: green;"&gt;// Declare a list of type string&lt;/span&gt;&lt;br /&gt;       GenericList&lt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&gt; list2 = &lt;span style="color: blue;"&gt;new&lt;/span&gt; GenericList&lt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;&gt;();&lt;br /&gt;&lt;br /&gt;       &lt;span style="color: green;"&gt;// Declare a list of type ExampleClass&lt;/span&gt;&lt;br /&gt;       GenericList&lt;exampleclass&gt; list3 = &lt;span style="color: blue;"&gt;new&lt;/span&gt; GenericList&lt;exampleclass&gt;();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;h1 class="heading"&gt;Generics Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;Use generic types to maximize code reuse, type safety, and performance.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;The most common use of generics is to create collection classes.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;The .NET Framework class library contains several new generic collection classes in the &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/system.collections.generic%28VS.80%29.aspx"&gt;System.Collections.Generic&lt;/a&gt;&lt;/span&gt; namespace. These should be used whenever possible in place of classes such as &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/system.collections.arraylist%28VS.80%29.aspx"&gt;ArrayList&lt;/a&gt;&lt;/span&gt; in the &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/system.collections%28VS.80%29.aspx"&gt;System.Collections&lt;/a&gt;&lt;/span&gt; namespace.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;You can create your own generic interfaces, classes, methods, events and delegates.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Generic classes may be constrained to enable access to methods on particular data types.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Information on the types used in a generic data type may be obtained at run-time by means of reflection.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-8869953545073628373?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/8869953545073628373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=8869953545073628373' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8869953545073628373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/8869953545073628373'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/generics-in-c.html' title='Generics  in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-5658122738987524632</id><published>2008-12-13T23:30:00.001-08:00</published><updated>2008-12-13T23:30:42.908-08:00</updated><title type='text'>Events  in C#</title><content type='html'>&lt;div class="title"&gt;Events &lt;!----&gt;&lt;/div&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Events provide a way for a &lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/0b0thckt%28VS.80%29.aspx"&gt;class&lt;/a&gt; or object to notify other classes or objects when something of interest happens. The class that sends (or &lt;i&gt;raises&lt;/i&gt;) the event is called the &lt;i&gt;publisher&lt;/i&gt; and the classes that receive (or &lt;i&gt;handle&lt;/i&gt;) the event are called &lt;i&gt;subscribers&lt;/i&gt;.&lt;/p&gt; &lt;p&gt;In a typical C# Windows Forms or Web application, you subscribe to events raised by controls such as buttons and list boxes. You can use the Visual C# integrated development environment (IDE) to browse the events that a control publishes and select the ones that you want to handle. The IDE automatically adds an empty event handler method and the code to subscribe to the event. For more information, see &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/ms366768%28VS.80%29.aspx"&gt;How to: Subscribe to and Unsubscribe from Events (C# Programming Guide)&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt; &lt;h1 class="heading"&gt;Events Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Events have the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;The publisher determines when an event is raised; the subscribers determine what action is taken in response to the event.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;An event can have multiple subscribers. A subscriber can handle multiple events from multiple publishers.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Events that have no subscribers are never called.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Events are commonly used to signal user actions such as button clicks or menu selections in graphical user interfaces.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;When an event has multiple subscribers, the event handlers are invoked synchronously when an event is raised. To invoke events asynchronously, see &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/2e08f6yc%28VS.80%29.aspx"&gt;Calling Synchronous Methods Asynchronously&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Events can be used to synchronize threads.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;In the .NET Framework class library, events are based on the &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/system.eventhandler%28VS.80%29.aspx"&gt;EventHandler&lt;/a&gt;&lt;/span&gt; delegate and the &lt;span class="linkTerms"&gt;&lt;a id="ctl00_rs1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/system.eventargs%28VS.80%29.aspx"&gt;EventArgs&lt;/a&gt;&lt;/span&gt; base class.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-5658122738987524632?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/5658122738987524632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=5658122738987524632' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5658122738987524632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/5658122738987524632'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/events-in-c.html' title='Events  in C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-4633124996148703816</id><published>2008-12-13T23:29:00.000-08:00</published><updated>2008-12-13T23:30:04.031-08:00</updated><title type='text'>Delegates  In C#</title><content type='html'>&lt;div class="title"&gt;Delegates &lt;!----&gt;&lt;/div&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;A &lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/900fyy8e%28VS.80%29.aspx"&gt;delegate&lt;/a&gt; is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method. The delegate method can be used like any other method, with parameters and a return value, as in this example:&lt;/p&gt; &lt;div class="libCScode" id="ctl00_rs1_mainContentContainer_ctl02_CSharp"&gt;&lt;div class="CodeSnippetTitleBar"&gt;&lt;div class="CodeDisplayLanguage"&gt;C#&lt;/div&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;pre class="libCScode" style="white-space: pre-wrap;" id="ctl00_rs1_mainContentContainer_ctl02CSharp" space="preserve"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; delegate &lt;span style="color: blue;"&gt;int&lt;/span&gt; PerformCalculation(&lt;span style="color: blue;"&gt;int&lt;/span&gt; x, &lt;span style="color: blue;"&gt;int&lt;/span&gt; y);&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Any method that matches the delegate's signature, which consists of the return type and parameters, can be assigned to the delegate. This makes is possible to programmatically change method calls, and also plug new code into existing classes. As long as you know the delegate's signature, you can assign your own delegated method.&lt;/p&gt; &lt;p&gt;This ability to refer to a method as a parameter makes delegates ideal for defining callback methods. For example, a sort algorithm could be passed a reference to the method that compares two objects. Separating the comparison code allows the algorithm to be written in a more general way.&lt;/p&gt; &lt;h1 class="heading"&gt;Delegates Overview&lt;/h1&gt;&lt;div id="sectionSection0" class="seeAlsoNoToggleSection"&gt; &lt;p&gt;Delegates have the following properties:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p&gt;Delegates are similar to C++ function pointers, but are type safe.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Delegates allow methods to be passed as parameters.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Delegates can be used to define callback methods.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Delegates can be chained together; for example, multiple methods can be called on a single event.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;Methods don't need to match the delegate signature exactly. For more information, see &lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/library/ms173174%28VS.80%29.aspx"&gt;Covariance and Contravariance&lt;/a&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p&gt;C# version 2.0 introduces the concept of &lt;a id="ctl00_rs1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/library/0yw3tz5k%28VS.80%29.aspx"&gt;Anonymous Methods&lt;/a&gt;, which permit code blocks to be passed as parameters in place of a separately defined method.&lt;/p&gt; &lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1391330880345771186-4633124996148703816?l=belbinsontoby.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://belbinsontoby.blogspot.com/feeds/4633124996148703816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1391330880345771186&amp;postID=4633124996148703816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4633124996148703816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1391330880345771186/posts/default/4633124996148703816'/><link rel='alternate' type='text/html' href='http://belbinsontoby.blogspot.com/2008/12/delegates-in-c.html' title='Delegates  In C#'/><author><name>Belbinson Toby</name><uri>http://www.blogger.com/profile/06139758804333551220</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='22' src='http://2.bp.blogspot.com/-4U4ICTUzpVI/TyXX2NIKb7I/AAAAAAAAAaQ/4pjW4rBPW60/s220/Gold-Windows-XIP-Logo-psd5800.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1391330880345771186.post-2818176101810369893</id><published>2008-12-13T23:28:00.002-08:00</published><updated>2008-12-13T23:29:07.918-08:00</updated><title type='text'>Indexers in C#</title><content type='html'>&lt;div class="title"&gt;Indexers&lt;!----&gt;&lt;/div&gt;&lt;!--Content type: DocStudio. Transform: devdiv2mtps.xslt.--&gt;   &lt;p&gt; &lt;/p&gt;&lt;p&gt;Indexers permit instances of a class or struct to be indexed in the same way as arrays. Indexers are similar to &lt;a id="ctl00_rs1_mainContentContainer_ctl01" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl01',this);" href="http://msdn.microsoft.com/en-us/library/x9fsa0sw%28VS.80%29.aspx"&gt;properties&lt;/a&gt; except that their accessors take parameters.&lt;/p&gt; &lt;p&gt;In the following example, a generic class is defined and provided with simple &lt;a id="ctl00_rs1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/library/ms228503%28VS.80%29.aspx"&gt;get&lt;/a&gt; and &lt;a id="ctl00_rs1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_rs1_mainContentContain
