<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fun stuff with C# Archives - Dragonsoft Technology View</title>
	<atom:link href="https://blog.dragonsoft.us/category/technology/fun-stuff-with-c/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.dragonsoft.us/category/technology/fun-stuff-with-c/</link>
	<description>Talk about Technologies, Software Architecture and Management</description>
	<lastBuildDate>Wed, 26 May 2021 03:17:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.dragonsoft.us/wp-content/uploads/2022/04/logo-main-bw-150x150.png</url>
	<title>Fun stuff with C# Archives - Dragonsoft Technology View</title>
	<link>https://blog.dragonsoft.us/category/technology/fun-stuff-with-c/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">2577970</site>	<item>
		<title>Which came first &#8211; the chicken or the egg &#8211; WPF, Developers and Designers &#8211; old tale</title>
		<link>https://blog.dragonsoft.us/2011/03/17/which-came-first-the-chicken-or-the-egg-wpf-developers-and-designers-old-tale/</link>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Fri, 18 Mar 2011 02:11:27 +0000</pubDate>
				<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[Technology]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=1234</guid>

					<description><![CDATA[<p>Nothing is more of the truth then old tales. Some long time ago Sean Sexton said If you’re a developer doing WPF development, you really need to be using Expression Blend. Yes, I know the party line on WPF development runs something like this: Every Dev team should have at<a class="moretag" href="https://blog.dragonsoft.us/2011/03/17/which-came-first-the-chicken-or-the-egg-wpf-developers-and-designers-old-tale/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2011/03/17/which-came-first-the-chicken-or-the-egg-wpf-developers-and-designers-old-tale/">Which came first &#8211; the chicken or the egg &#8211; WPF, Developers and Designers &#8211; old tale</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Nothing is more of the truth then old tales. Some long time ago <a href="http://stuff.seans.com/" target="_blank">Sean Sexton</a> said</p>
<blockquote><p>If you’re a developer doing WPF development, you really need to be using Expression Blend.</p>
<p>Yes, I know the party line on WPF development runs something like this:</p>
<ul>
<li>Every Dev team should have at least 1 developer and 1 designer</li>
<li>Developers can’t design decent-looking GUIs to save their soul</li>
<li>Designers can’t be trusted with code, or anything close to code (excepting XAML)</li>
<li>Devs will open a project in Visual Studio and do all of their work there</li>
<li>Designers will open the same project in Blend and do all of their work there</li>
<li>Devs wear button-up shirts that don’t match their Dockers</li>
<li>Designers wear brand-name labels and artsy little berets</li>
</ul>
</blockquote>
<p>While much has changed since &#8211; language and controls evolved, iEverything is the mantra, Visual Studio got decent UI designer for WPF/Silverlight &#8211; but our mentality never changes once set &#8211; developers are all about code, and would use XAML editor rather than any UI tools, and UX folks would scream and bash them for not using proper tools.</p>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2011/03/17/which-came-first-the-chicken-or-the-egg-wpf-developers-and-designers-old-tale/">Which came first &#8211; the chicken or the egg &#8211; WPF, Developers and Designers &#8211; old tale</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1234</post-id>	</item>
		<item>
		<title>Crystal Reports 2008 and ASP.Net : speed up the first session</title>
		<link>https://blog.dragonsoft.us/2009/09/23/crystal-reports-2008-and-asp-net-speed-up-first-session/</link>
					<comments>https://blog.dragonsoft.us/2009/09/23/crystal-reports-2008-and-asp-net-speed-up-first-session/#comments</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Wed, 23 Sep 2009 12:21:04 +0000</pubDate>
				<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[Web-design]]></category>
		<category><![CDATA[.net 2.0]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[certificate revocation List]]></category>
		<category><![CDATA[code access security]]></category>
		<category><![CDATA[crl]]></category>
		<category><![CDATA[crl.verisign.net]]></category>
		<category><![CDATA[crystal reports viewer]]></category>
		<category><![CDATA[generatePublisherEvidence]]></category>
		<category><![CDATA[Slow start up]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=1010</guid>

					<description><![CDATA[<p>Did you ever noticed that after restart of the IIS ASP.Net page which has Crystal Reports Viewer would take much longer to come up? Some of it is expected since on initial start up, a number of Crystal assemblies and objects need to be created and this does take time. I<a class="moretag" href="https://blog.dragonsoft.us/2009/09/23/crystal-reports-2008-and-asp-net-speed-up-first-session/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2009/09/23/crystal-reports-2008-and-asp-net-speed-up-first-session/">Crystal Reports 2008 and ASP.Net : speed up the first session</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Did you ever noticed that after restart of the IIS ASP.Net page which has Crystal Reports Viewer would take much longer to come up?</p>
<p>Some of it is expected since on initial start up, a number of Crystal assemblies and objects need to be created and this does take time.<br />
I want to emphasize that discussion below is related to the first run of any reports. We have to actually restart/reset IIS to see problem again.</p>
<blockquote><p>Note: There was a question about IIS&#8217; Application Pools recycling which could cause similar effect. Make sure your application pool <a href="http://support.microsoft.com/kb/332088" target="_blank">is set properly</a>.</p></blockquote>
<p><strong>Setting up a playground</strong></p>
<p>Let&#8217;s assume ASP.Net pages were already migrated to use .Net 3.x and look at what happen behind the scene.</p>
<p>Remember that after restart IIS starts from ground up. This means several things in respect to our page content:</p>
<ul>
<li>.Net assemblies need to be preloaded and validated if necessary.<br />
Since Crystal Reports 2008 comes as .Net 2.0-based core and we may already moved to .Net 3.x, CR2008 Engine and some additional files need to be loaded and validated aside from one which already used by any previously loaded pages.</li>
<li>For each session engine would create a cached version of RPT file in temp folder.</li>
<li>Some code would have to be brought to the client machine for Viewer to operate properly.</li>
<li>Database connection established, data retrieved, processed, paged and sent to the client Viewer.</li>
</ul>
<p>That about it, now we ready to work with reports. Please notice that after that initial load, any other reports would come up faster. We could even close the browser or use another browser (ex. go from IE to FF) and it would be still faster than the first time, so there is something important about the first step above&#8230;</p>
<p><strong>Combing the sand</strong></p>
<p>Let&#8217;s try to break the IIS initialization process to get more detailed view.</p>
<p>Since we already had some ASP.Net pages loaded before coming to CR related page, we could disregard .Net core initialization procedure. It is there on IIS side: used and ready.</p>
<p>Ok, next thing is CR engine related stuff. There is some 5Mb of files in <strong>crystalreportviewers12</strong> folder to support CR Viewer in ASP.Net and we need to send some of them over the network. In addition to that there is Crystal Reports Engine assemblies which need to be loaded by IIS at the time of the first use. And this is our spot to dig.</p>
<p>If we try and trace what exactly going on we would notice that aside from IIS loading a few dozen assemblies, there is also process associated with trying connect to CRL.VERISIGN.NET.</p>
<p><strong>What is it?</strong></p>
<p>&#8220;Problem&#8221; is that assemblies are Authenticode signed and therefore need to be verified or it technical terms they need to be checked against <a href="http://technet.microsoft.com/en-us/library/bb457027.aspx" target="_blank">Certificate Revocation List (CRL)</a> by <a href="http://msdn.microsoft.com/en-us/library/system.security.policy.publisher.aspx" target="_blank">Publisher</a> for <a href="http://msdn.microsoft.com/en-us/library/930b76w0.aspx" target="_blank">Code Access Security (CAS)</a>.</p>
<p>Default behavior is that they need to be verified by the certificate authority. If certificate is not present on the same machine (I have my doubts that SAP doing anything about that, but I could be wrong), validation need to be done via central repository mentioned above, or if machine does not have network/internet access the .NET thread might timeout waiting to connect.</p>
<blockquote><p>Yes, by performing strong name signing of assemblies or placing the CA certificate on the same machine issue would be avoided, but it seems not being a case.</p></blockquote>
<p><strong>Building the castle</strong></p>
<p>Since assemblies are provided by SAP, we cannot remove digital signature and it is a hassle to keep certificates current by obtaining them from CA every time they expire. Let&#8217;s concentrate on the Publisher mentioned above and turn it off.</p>
<blockquote><p><em>It is all-or-nothing solution since it would require turning off CRC for the entire IIS.</em></p></blockquote>
<p>When working with regular .Net apps, it can be done on the app level (assuming <a href="http://support.microsoft.com/kb/936707" target="_blank">we already have fix for .Net 2.0</a>) by adding the following section in &lt;Application&gt;.exe.config</p>
<pre class="brush: xml; title: ; notranslate">&lt;configuration&gt;
  &lt;runtime&gt;
    &lt;generatePublisherEvidence enabled=&quot;false&quot;/&gt;
  &lt;/runtime&gt;
&lt;/configuration&gt;</pre>
<p>This new element described in <a href="http://msdn.microsoft.com/en-us/library/bb629393.aspx" target="_blank">this MSDN article</a>. Interesting note there (why not to turn it then by default? Oh, security concerns&#8230; UAC anyone?):</p>
<blockquote><p>We recommend that services use the <span><span>&lt;generatePublisherEvidence&gt;</span></span> element to improve startup performance. Using this element can also help avoid delays that can cause a time-out and the cancellation of the service startup.</p></blockquote>
<p>Since there is no such config file for our ASP.Net app (web.config would not work here, because it defines settings that are only AppDomain wide and we need process wide for aspnet_isapi.dll being the hosting environment for the runtime), we would have to turn code access security (CAS) publisher policy off for the entire IIS.<br />
There are two options:</p>
<ul>
<li>Create a file called w3wp.exe.config (for IIS6, or aspnet_wp.exe.config for IIS5). This will affect all .NET based web applications on the system.</li>
<li>Or to specify this in machine.config, but then this affects every .NET application on the machine and is not available for override in individual Apps.</li>
</ul>
<p><strong>Adding the summer cabin</strong></p>
<p>There is one more step which could be taken to improve performance by preloading some of the core assemblies while site visitor is doing something else.<br />
I wouldn&#8217;t go into much details here, since it is implementation/application environment specific, but just give a hint:</p>
<ul>
<li>some other place in application, create a background process which would create CR document object, load some not essential report file, retrieve some data and then disapear without the trace. This would allow Crystal Reports Engine being initialized in the background offsetting time needed for the actual CR related page load. Don&#8217;t force garbage collection though, this may cancel desired effect.</li>
</ul>
<p><strong>Results</strong></p>
<p>In some situation I observed 50% to 70% drop in start-up time&#8230;<br />
Have fun!</p>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2009/09/23/crystal-reports-2008-and-asp-net-speed-up-first-session/">Crystal Reports 2008 and ASP.Net : speed up the first session</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2009/09/23/crystal-reports-2008-and-asp-net-speed-up-first-session/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1010</post-id>	</item>
		<item>
		<title>File locks or when garbage collection goes bad</title>
		<link>https://blog.dragonsoft.us/2009/03/02/file-locks-or-when-garbage-collection-goes-bad/</link>
					<comments>https://blog.dragonsoft.us/2009/03/02/file-locks-or-when-garbage-collection-goes-bad/#respond</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Mon, 02 Mar 2009 12:23:41 +0000</pubDate>
				<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[cannot delete file]]></category>
		<category><![CDATA[file lock]]></category>
		<category><![CDATA[garbage collection manager]]></category>
		<category><![CDATA[manage garbage collection process]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=842</guid>

					<description><![CDATA[<p>With introduction of garbage collection (System.GC name space) in .Net, life of the Windows programmer become easy &#8211; no need to worry about releasing objects, code become simpler, etc. In &#8220;old&#8221; time one would need to use Interfaces to achieve similar functionality and it does have some advantage even over GC &#8211;<a class="moretag" href="https://blog.dragonsoft.us/2009/03/02/file-locks-or-when-garbage-collection-goes-bad/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2009/03/02/file-locks-or-when-garbage-collection-goes-bad/">File locks or when garbage collection goes bad</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>With introduction of <a href="http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)" target="_blank">garbage collection</a> (System.GC name space) in .Net, life of the Windows programmer become easy &#8211; no need to worry about releasing objects, code become simpler, etc.<br />
In &#8220;old&#8221; time one would need to use Interfaces to achieve similar functionality and it does have some advantage even over GC &#8211; immediate garbage collection or release of allocated resources/objects.</p>
<p>When writing code in .Net some of us take many things for granted and not always keep in mind that many operations are performed in the context of the unmanaged code or in the &#8220;old way&#8221;&#8230;</p>
<p>File operations or legacy code wrappers are perfect example.<br />
Just because library is available as managed code, it does not mean that everything has ability to &#8220;self-heal&#8221;.<br />
For example in code file is open for edit with lock being placed.<br />
If the file in not closed explicitly, it would be a responsibility of the owner process to release the lock at the time of releasing associated resources &#8211; when process is destroyed.</p>
<p>With garbage collection, just because we are no longer using/owning the process/object, it does not mean that it has been destroyed immediately after. GC management core will release object when it &#8220;feels&#8221; fit, therefore introducing latency into the process.</p>
<p>Off course, proper way would be to be more careful within the code and make sure any locks are released in managed and predictable way: Open/Close, Lock/Unlock, &#8230; Easy solution, but not always accessible, especially when working with 3rd party libraries.</p>
<p>So instead, we can force GC manager to &#8220;collect garbage&#8221; in-place with the following small code:</p>
<pre class="brush: csharp; title: ; notranslate">// See code follow up below
System.GC.Collect();
System.GC.WaitForPendingFinalizers();</pre>
<p>What does it do?<br />
First call will instruct GC manager to start the process (<a href="http://msdn.microsoft.com/en-us/library/system.gc.collect.aspx" target="_blank">1</a>), while second (<a href="http://msdn.microsoft.com/en-us/library/system.gc.waitforpendingfinalizers.aspx" target="_blank">2</a>) will make sure that we wait for process to be completed.</p>
<p>In the case of the file locks, only after GC has released process which placed the lock in the first place, we can manipulate with the file (ex. delete, rename, move).</p>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2009/03/02/file-locks-or-when-garbage-collection-goes-bad/">File locks or when garbage collection goes bad</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2009/03/02/file-locks-or-when-garbage-collection-goes-bad/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">842</post-id>	</item>
		<item>
		<title>Assert is your friend&#8230; not an end-user&#8217;s</title>
		<link>https://blog.dragonsoft.us/2009/01/15/assert-is-your-friend-not-end-users/</link>
					<comments>https://blog.dragonsoft.us/2009/01/15/assert-is-your-friend-not-end-users/#respond</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Thu, 15 Jan 2009 22:24:22 +0000</pubDate>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[assert]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[debug.assert]]></category>
		<category><![CDATA[delphi]]></category>
		<category><![CDATA[trace.assert]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=777</guid>

					<description><![CDATA[<p>As a long time Delphi and C# programmer one become used to some features of the language and may not go deep into &#8220;philosophical&#8221; thinking about such features. This often happen with Asserts&#8230; What is Assert or Assertion? By its definition Assert: state categorically affirm: to declare or affirm solemnly<a class="moretag" href="https://blog.dragonsoft.us/2009/01/15/assert-is-your-friend-not-end-users/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2009/01/15/assert-is-your-friend-not-end-users/">Assert is your friend&#8230; not an end-user&#8217;s</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As a long time Delphi and C# programmer one become used to some features of the language and may not go deep into &#8220;philosophical&#8221; thinking about such features. This often happen with <strong>Asserts</strong>&#8230;</p>
<h3>What is Assert or Assertion?</h3>
<p>By its definition <strong>Assert</strong>:</p>
<ul>
<li>state categorically</li>
<li>affirm: to declare or affirm solemnly and formally as true</li>
<li>insist: assert to be true</li>
<li>In Computing (<a href="http://en.wikipedia.org/wiki/Assert" target="_blank">wiki</a>): &#8220;an <strong>assert</strong> is a predicate (i.e., a true–false statement) placed in a program to indicate that the developer <em>thinks</em> that the predicate is always true at that place&#8221;</li>
</ul>
<p>In general, using <strong>assert</strong> in the code proven to be useful in many situations because it &#8220;<a href="http://msdn.microsoft.com/en-us/library/aa326827.aspx" target="_blank">checks for a condition and outputs the call stack if the condition is <strong>false</strong></a>&#8221; and it could help to debug some strange situations in the code.</p>
<h3><a href="http://www.codeproject.com/KB/cpp/assertisyourfriend.aspx" target="_blank">Assert is your friend</a></h3>
<p>This method is for programmers to use. But what happen often when something is convenient, it started to be used excessively. Why it is happening?</p>
<p>Let&#8217;s look at the declaration of <strong>Assert</strong> in C# (3.x). There are two versions of the <strong>Assert()</strong>: <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debug.assert.aspx" target="_blank"><strong>Debug.Assert()</strong></a> and <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.trace.assert.aspx" target="_blank"><strong>Trace.Assert()</strong></a>, both in <strong>System.Diagnostics </strong>namespace.</p>
<pre class="brush: csharp; title: ; notranslate">
// Checks for a condition and outputs the call stack
// if the condition is false

&#x5B;ConditionalAttribute(&quot;TRACE&quot;)]
public static void Assert(bool condition)

&#x5B;ConditionalAttribute(&quot;TRACE&quot;)]
public static void Assert(bool condition, string message)

&#x5B;ConditionalAttribute(&quot;DEBUG&quot;)]
public static void Assert(bool condition)

&#x5B;ConditionalAttribute(&quot;DEBUG&quot;)]
public static void Assert(bool condition, string message)</pre>
<p>As we can see from above code, Assert is to be used for <span style="text-decoration: underline;">Testing</span> and <span style="text-decoration: underline;">Debugging</span> and therefore should not be used as a way to present any information to the <strong>end-user.</strong></p>
<h3>Helping yourself</h3>
<p>As useful as it seems, even then Assert infrastructure may not be used to full extend. In the sample declarations above we can see that logic can be invoked with and without providing any additional information.<br />
Imagine how useful is a message &#8220;Project raised an Assert in line X&#8221; compare to &#8220;Project raised an Assert with the Message in line X&#8221;.<br />
First option gives you idea where something failed, where second actually tells you what went wrongand where. Let&#8217;s use power of the tool-set and provide ourselves with useful information.</p>
<h3>Assert is NOT for an end-user</h3>
<p>I was asked recently (this seems to be a ongoing discussion) &#8211; &#8220;Why a programmer should not be using asserts as a regular approach in code conditions validation even when it comes to a production code?&#8221;</p>
<p>By default, Assert would show a message box with some information and the current Call Stack. This information, while being helpful to the developer, would not tell much to the user.</p>
<p>With custom <span><a id="ctl00_rs1_mainContentContainer_ctl73" onclick="function onclick() { function onclick() { function onclick() { function onclick() { Track('ctl00_rs1_mainContentContainer_cpe285485_c|ctl00_rs1_mainContentContainer_ctl73',this); } } } }" href="http://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener.aspx"><span style="color: #0033cc;">TraceListener</span></a></span> introduced, message can be hidden from the user and information could be stored, but it is not how it should be used by definition.</p>
<p>If information is expected to be presented to the user in any form, it could be achieved in a form not an exceptional, intended for debugging, situation, but by using regular methods: message box, application log, Windows event log, etc.<br />
Even in the case of component development it is desired to use exceptions (<strong>raise/throw</strong>) to &#8220;bubble&#8221; proper message to the error handling layer.</p>
<blockquote><p>The <span><span class="input">throw</span></span> statement is used to signal the occurrence of an anomalous situation (exception) during the program execution.</p></blockquote>
<h3>Assert is a conditional logic</h3>
<p>Last, final and probably major concern here is that in Release environment Debug and even Trace functionality would be disabled and therefore, any code/logic which depend on Assert() would be suppressed and all the nice validations became worthless (see declaration above)&#8230; and Access Violation errors starting pop up unexpectedly.</p>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2009/01/15/assert-is-your-friend-not-end-users/">Assert is your friend&#8230; not an end-user&#8217;s</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2009/01/15/assert-is-your-friend-not-end-users/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">777</post-id>	</item>
		<item>
		<title>.Net and Design Patterns</title>
		<link>https://blog.dragonsoft.us/2008/12/08/net-and-design-patterns/</link>
					<comments>https://blog.dragonsoft.us/2008/12/08/net-and-design-patterns/#respond</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Mon, 08 Dec 2008 21:51:51 +0000</pubDate>
				<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[.net C#]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[OOD]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[wpf design patterns]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=641</guid>

					<description><![CDATA[<p>Evolution has a spiral nature&#8230; it is true for any science, process, or development. Not long time ago Waterfall Model of development prevailed. Very formalized, well described and structured, very structured&#8230; and it was &#8220;too much&#8221; which killed it&#8230; like a grandpa, it collected a lot of knowledge and experience,<a class="moretag" href="https://blog.dragonsoft.us/2008/12/08/net-and-design-patterns/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2008/12/08/net-and-design-patterns/">.Net and Design Patterns</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Evolution has a spiral nature&#8230; it is true for any science, process, or development.</p>
<p>Not long time ago Waterfall Model of development prevailed. Very formalized, well described and structured, very structured&#8230; and it was &#8220;too much&#8221; which killed it&#8230; like a grandpa, it collected a lot of knowledge and experience, but he was to old and slow to keep up with the grandson&#8230; So was WF model &#8211; developers wanted something better and simpler, with built-in flexibility and after few iterations we&#8217;ve got &#8220;Agile model&#8221; and &#8220;XP programming&#8221; emerged. &#8220;Spiral&#8221; development cycles&#8230; &#8220;loose&#8221; modeling&#8230; like with JPEG, developers got &#8220;loose compression&#8221; of software process definition.</p>
<p>Not that we are loosing quality of the development, but we define the development process with desired level of formality/quality.</p>
<p>Remember in &#8220;Pirates of Caribbean&#8221; &#8211; pirates have &#8220;the pirate code&#8221;. Not being the law, it was a code of conduct which was helping keep the structure and discipline.</p>
<p>Same for &#8220;free spirit&#8221; development models, there is the need for some &#8220;guidelines&#8221; or &#8220;rules&#8221; everybody can understand and follow if want to achieve structure and efficiency. For the process there is an <a href="http://www.agilemodeling.com/essays/agileSoftwareDevelopment.htm" target="_blank">Agile methodology</a>, and for the code/architecture there are <a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)" target="_blank">Design Patterns</a>.</p>
<p>First introduced over 30 years ago, term &#8220;<strong>Patterns</strong>&#8221; surfaced in software industry several time: originally <a href="http://en.wikipedia.org/wiki/Pattern_(architecture)" target="_blank">in 1977</a>, then in <a href="http://c2.com/doc/oopsla87.html" target="_blank">1987</a> and then finally in <a href="http://en.wikipedia.org/wiki/Design_Patterns" target="_blank">1994</a>.<br />
Since that time and Object Oriented Design becoming main stream in Software Industry it transformed into a common terminology.<br />
It still come in &#8220;waves&#8221; to one company or another, coming ashore and and then retracting back to the sea of the theories. But with Object Oriented Programming being a mainstream in evolution of software development, <strong>Patterns</strong> or <strong>Design Patterns</strong> knowledge become a common base.</p>
<p>Today you hear about it everywhere &#8211; &#8220;What <strong><em>design pattern</em></strong> did you use?&#8221;, &#8220;<strong><em>application blocks</em></strong>&#8220;, etc.</p>
<p>To think about it, there is nothing new here. As an OO developer you may used it just a minute ago.</p>
<p>So let&#8217;s name a few basic one (I am going to use pattern classification presented <a href="http://www.dofactory.com/Patterns/Patterns.aspx" target="_blank">here</a> or you can refer to The Source &#8211; <a href="http://en.wikipedia.org/wiki/Design_Patterns" target="_blank">&#8220;Design  Patterns&#8221; by Gamma/Helm/Johnson/Vlissides</a> (<a href="http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1228802288&amp;sr=1-1" target="_blank">Amazon</a>)):</p>
<ul>
<li><strong>Abstract Factory</strong> &#8211; allows manage/create instances of several types of classes &#8211; generic access.<br />
A-ha! In .Net the perfect example would be generics and reflection &#8211; there you are working with objects without precise knowledge of their type or parameters.</li>
<li><strong>Singleton</strong> &#8211; have you ever created global instance of the class? This is a one example for you.</li>
<li><strong>Adapter</strong> &#8211; we heard it somewhere recently&#8230; Aaaa&#8230; OleDBDataAdapter&#8230; From MSDN: &#8220;The OleDbDataAdapter serves as a bridge between a DataSet and data source for retrieving and saving data&#8221;</li>
<li><strong>Bridge</strong> &#8211; have you moved from Single/mono-design applications to C/S or created front-end ASP.Net page for your Application Server back-end? Then you have separated interface from implementation of the logic, or used a Bridge pattern.</li>
<li><strong>Proxy</strong> &#8211; Accessing your web-service from your code? Then you have most likely using some sort of Proxy class.</li>
</ul>
<p><span id="more-641"></span>And then you look at WPF and see more complex like <a href="http://www.orbifold.net/default/?p=550" target="_blank">WPF patterns.</a></p>
<p>You start with just 3 groups of two dozen design patterns and you end up with many more. Some are more common then others. As it did happen with XP and Agile, and other &#8220;new&#8221; things, it all falls back to the knowledge of terminology and &#8220;buzz&#8221; words.</p>
<p>What does knowledge of DP give you? In reality it can come to &#8211; &#8220;not much&#8221; and &#8220;a lot&#8221;. Statements contradicting each other? Well.</p>
<p>Let&#8217;s look at the definition:</p>
<blockquote><p><strong>Design Pattern</strong> is a general reusable solution to a commonly occurring problem in software design. It helps a designer/developer/architect get a design &#8220;right&#8221; faster.</p></blockquote>
<p>As you can see from definition, you may know them from acquired knowledge, common experience. After several years of development, you have your own patterns/templates, common practices in solving common problems. As a result, learning about &#8220;Design Patterns&#8221; may not  give you much of <em>the new knowledge</em>, but may help establish common grounds for discussion with the friend in next cubicle.</p>
<p>Ok, lets come back to original idea of .Net and design patterns. Why is it so important these days? Is it important to bring two together?</p>
<p>.Net framework, C# in particular, become a fine example of Object Oriented Design implementation. With language structures and Object Models present in .Net framework, it is important to understand principles of Object Oriented Design and Object Oriented Programming.</p>
<blockquote><p><strong>Object-oriented design (OOD)</strong> is a programming paradigm that began in the late 60&#8217;s as software programs became more and more complex. The idea behind the approach was to build software systems by modeling them based on the real-world objects that they were trying to represent.</p></blockquote>
<blockquote><p><strong>Object-oriented programming (OOP)</strong> is a programming paradigm that uses &#8220;objects&#8221; and their interactions to design applications and computer programs. Programming techniques may include features such as encapsulation, modularity, polymorphism, and inheritance.</p></blockquote>
<p>Combine them all and you will get .Net 3.x &#8211; WPF/WCF/LINQ frameworks. With <a href="http://www.orbifold.net/default/?p=550" target="_blank">WPF patterns</a> and all, in order to get most out of the framework theory part of OOD/OOP become even more important because it is built-in/core part of the new concepts behind class/event/organization model of the latest edition of the framework.</p>
<p>You just thought that you know it all about C#? Well&#8230; it is time to start the next learning cycle. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>PS. There are few things to read and watch:</p>
<ul>
<li><a href="http://blogs.msdn.com/johngossman/default.aspx" target="_blank">&#8220;Tales from the Smart Client&#8221;</a> by John Gossman, Microsoft Architect for WPF and Silverlight. &#8230; You will find many posts about design and patterns in WPF.</li>
<li>Another good source is <a href="http://www.dnrtv.com" target="_blank">dnrTV!</a>. It now has more then a hundred shows discussing different aspects of .Net framework application: training videos, interviews and more&#8230;</li>
</ul>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2008/12/08/net-and-design-patterns/">.Net and Design Patterns</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2008/12/08/net-and-design-patterns/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">641</post-id>	</item>
		<item>
		<title>ASP.Net/WF : New built-in .Net Charting control</title>
		<link>https://blog.dragonsoft.us/2008/11/26/aspnet-new-build-in-net-charting-control/</link>
					<comments>https://blog.dragonsoft.us/2008/11/26/aspnet-new-build-in-net-charting-control/#comments</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Wed, 26 Nov 2008 18:14:38 +0000</pubDate>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web-design]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[asp:chart]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[chart support in .Net]]></category>
		<category><![CDATA[charting]]></category>
		<category><![CDATA[Dundas]]></category>
		<category><![CDATA[winforms]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=620</guid>

					<description><![CDATA[<p>I was always for a &#8220;built-in&#8221; support of features in modern development environment. Even if it comes in basic form, we, as programmers, should have ability to do &#8220;basic&#8221; stuff without 3rd party involvement. There are plenty of 3rd party solutions on the market which would help you include some kind<a class="moretag" href="https://blog.dragonsoft.us/2008/11/26/aspnet-new-build-in-net-charting-control/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2008/11/26/aspnet-new-build-in-net-charting-control/">ASP.Net/WF : New built-in .Net Charting control</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I was always for a &#8220;built-in&#8221; support of features in modern development environment. Even if it comes in basic form, we, as programmers, should have ability to do &#8220;basic&#8221; stuff without 3rd party involvement.</p>
<p>There are plenty of 3rd party solutions on the market which would help you include some kind of charting support with your ASP pages and WinForms applications &#8211; <a href="http://www.softwarefx.com/sfxNetProducts/ChartFX/wpf/" target="_blank" rel="noopener">ChartFX</a>, <a href="http://www.dundas.com/Products/Chart/NET/index.aspx" target="_blank" rel="noopener">Dundas Chart</a> &#8211; these are just few from many available on the market today.</p>
<p>As it turned out, Microsoft has decided to add out-of-the-box support for Charting as well &#8211; <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&amp;DisplayLang=en" target="_blank" rel="noopener">&lt;asp:chart runat=&#8221;server&#8221;/&gt;</a>.<br />
Read about it here &#8211; <a href="http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx" target="_blank" rel="noopener">New ASP.NET Charting Control: &lt;asp:chart runat=&#8221;server&#8221;/&gt;</a> by Scott Guthrie &#8211; everything you need to know about the .Net 3.5 framework new addition.</p>
<p>For  additional information also visit Alex Gorev&#8217;s <a href="http://blogs.msdn.com/alexgor/archive/2008/11/07/microsoft-chart-control-vs-dundas-chart-control.aspx" target="_blank" rel="noopener">blog</a>.</p>
<p><strong>Note 1</strong>: Even though caption says it is ASP.Net solution, in the original you would find link to WinForms sample as well.<br />
<strong>Note 2</strong>: Do not worry about Dundas copyright &#8211; &#8220;Microsoft acquired Dundas Data Visualization Intellectual Property in April 2007.&#8221;</p>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2008/11/26/aspnet-new-build-in-net-charting-control/">ASP.Net/WF : New built-in .Net Charting control</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2008/11/26/aspnet-new-build-in-net-charting-control/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">620</post-id>	</item>
		<item>
		<title>Windows 7 and multi-touch &#8211; continued</title>
		<link>https://blog.dragonsoft.us/2008/11/05/windows-7-and-multi-touch-continued/</link>
					<comments>https://blog.dragonsoft.us/2008/11/05/windows-7-and-multi-touch-continued/#comments</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Wed, 05 Nov 2008 19:14:39 +0000</pubDate>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[multi-touch]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[windows 7]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=582</guid>

					<description><![CDATA[<p>Some time ago I have wrote about steps Microsoft was making into multi-touch interface support inside Windows application. If you visited PDC 2008, then you probably already heard that Microsoft had officially presented a new .Net framework/API which would be available as part of Windows 7. If you have missed<a class="moretag" href="https://blog.dragonsoft.us/2008/11/05/windows-7-and-multi-touch-continued/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2008/11/05/windows-7-and-multi-touch-continued/">Windows 7 and multi-touch &#8211; continued</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Some time ago <a href="http://blog.dragonsoft.us/2008/05/29/windows-7-and-multi-touch/" target="_self">I have wrote</a> about steps Microsoft was making into multi-touch interface support inside Windows application.</p>
<p>If you visited PDC 2008, then you probably already heard that Microsoft had officially presented a new .Net framework/API which would be available as part of Windows 7.</p>
<p>If you have missed PDC 2008 this year, you can watch it online here</p>
<ul>
<li><a id="ctl00_MainPlaceHolder_TitleLink" href="http://channel9.msdn.com/pdc2008/PC17/">Developing for Microsoft Surface</a></li>
<li><a id="ctl00_MainPlaceHolder_TitleLink" href="http://channel9.msdn.com/pdc2008/PC03/">Windows 7: Developing Multi-touch Applications</a></li>
</ul>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2008/11/05/windows-7-and-multi-touch-continued/">Windows 7 and multi-touch &#8211; continued</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2008/11/05/windows-7-and-multi-touch-continued/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">582</post-id>	</item>
		<item>
		<title>Future of C# &#8211; v 4.0 at PDC 2008</title>
		<link>https://blog.dragonsoft.us/2008/11/05/future-of-c-40/</link>
					<comments>https://blog.dragonsoft.us/2008/11/05/future-of-c-40/#comments</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Wed, 05 Nov 2008 18:42:32 +0000</pubDate>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[anders hejlsberg]]></category>
		<category><![CDATA[c# 4.0]]></category>
		<category><![CDATA[pdc 2008]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=571</guid>

					<description><![CDATA[<p>Late August I have brought up a question about default parameters in Delphi. But it does not stop with just Delphi &#8211; C# did not have support for default parameters for years&#8230; Not anymore &#8211; default or optional parameters would appear in C# of some near future &#8211; .Net 4.0 (this<a class="moretag" href="https://blog.dragonsoft.us/2008/11/05/future-of-c-40/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2008/11/05/future-of-c-40/">Future of C# &#8211; v 4.0 at PDC 2008</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Late August I have brought up a <a href="http://blog.dragonsoft.us/2008/08/28/delphi-methods-and-default-values-convenience-or-contract-enforcement/" target="_self">question about default parameters</a> in Delphi. But it does not stop with just Delphi &#8211; C# did not have support for default parameters for years&#8230;</p>
<p>Not anymore &#8211; <a href="http://channel9.msdn.com/pdc2008/TL16/" target="_blank">default or optional parameters would appear in C# of some near future &#8211; .Net 4.0</a> (this is 70+ minutes you have to listen to):</p>
<ol>
<li>dynamic language support and <em>Dynamically Typed Objects</em></li>
<li>concurrent applications, multi-core support, parallel programming</li>
<li>befriend C# with VB#</li>
<li><em>default and named parameters</em></li>
<li><em>Compiler as service, compiler API, code delegate, code text as script</em></li>
<li>more&#8230;</li>
</ol>
<p>Being the father of Delphi and then C#, he could not resist from sharing/exploring further many ideas which we have seen since Delphi 1.0 &#8211; VCL, data access, and many other things.</p>
<p>I have always considered C# being a Delphi 2.0 &#8211; which Delphi could become if Anders would have an opportunity to extend it at Borland.</p>
<p>Few thoughts:</p>
<p>#1. very nice simplification to the coding practices. Too powerful perhaps? Well, generics were as such when introduced and now we cannot live without it&#8230; PHP/Python anyone? Delphi classes from C# without reflection, interfaces or delegation&#8230;</p>
<p>#3. Is interesting statement from Microsoft since they did try hard to decommission VB and have not succeeded. I think Borland/CodeGear has tried the same with Delphi and has not succeed with that either. Evolution of the language is inevitable, it has to follow the trend. And I am glad with <strong>Prism</strong> announced this is something which would be a thing of the past.</p>
<p>#4. default parameters&#8230; Finally&#8230; a named parameters? mmm&#8230; interesting&#8230;</p>
<p>#5 as component developer I would love to see this feature in Delphi for dynamic deployment. As a developer I am looking forward for Delphi scripting capabilities&#8230;</p>
<p>PS. It is nice to see an acknowledge of his work at Borland in his PDC2008 introduction</p>
<blockquote><p>Before joining Microsoft in 1996, Hejlsberg was one of the first employees of Borland International Inc. As principal engineer, he was the original author of Turbo Pascal, a revolutionary integrated development environment, and chief architect of its successor, Delphi.</p></blockquote>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2008/11/05/future-of-c-40/">Future of C# &#8211; v 4.0 at PDC 2008</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2008/11/05/future-of-c-40/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">571</post-id>	</item>
		<item>
		<title>Populate TreeView from table in ASP.Net</title>
		<link>https://blog.dragonsoft.us/2008/10/28/populate-treeview-from-table-in-aspnet/</link>
					<comments>https://blog.dragonsoft.us/2008/10/28/populate-treeview-from-table-in-aspnet/#comments</comments>
		
		<dc:creator><![CDATA[Serguei Dosyukov]]></dc:creator>
		<pubDate>Tue, 28 Oct 2008 21:49:51 +0000</pubDate>
				<category><![CDATA[Fun stuff with C#]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[populate treeview from table]]></category>
		<guid isPermaLink="false">http://blog.dragonsoft.us/?p=545</guid>

					<description><![CDATA[<p>I was asked today to help with code which would populate the TreeView control from database table in ASP.Net page. Since it is not a first time around and appear to be very common situation with dynamic pages, I thought it may be useful to write about it once and<a class="moretag" href="https://blog.dragonsoft.us/2008/10/28/populate-treeview-from-table-in-aspnet/"> Read more</a></p>
<p>The post <a href="https://blog.dragonsoft.us/2008/10/28/populate-treeview-from-table-in-aspnet/">Populate TreeView from table in ASP.Net</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I was asked today to help with code which would populate the TreeView control from database table in ASP.Net page.</p>
<p>Since it is not a first time around and appear to be very common situation with dynamic pages, I thought it may be useful to write about it once and then just refer to this post later.</p>
<ol>
<li>We have a table with the following structure:<br />
<table border="1">
<tbody>
<tr>
<td>ID</td>
<td>ParentID</td>
<td>Name</td>
</tr>
</tbody>
</table>
</li>
<li>We also have a stored procedure <strong>usp_GetGroupList</strong> which would return data from table above.</li>
<li>And on our ASP page we have a TreeView control called myTreeView</li>
</ol>
<p>Few things we are trying to achieve:</p>
<ol>
<li>Small code</li>
<li>Minimum of database access</li>
</ol>
<p>Well, code would not be too complex after all:</p>
<pre class="brush: csharp; title: ; notranslate">private void PopulateTree()
{
    // Populate dataset with data for later use
    DataSet dsList = new DataSet();
    SqlConnection conn = new SqlConnection(myConnectionString);
    conn.Open();
    try
    {
        SqlCommand cmd = new SqlCommand(&quot;usp_GetGroupList&quot;, conn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter adapt = new SqlDataAdapter(cmd);
        adapt.Fill(dsList);
    }
    finally
    {
        conn.Close();
    }

    // Clear the tree
    myTreeView.Nodes.Clear();
    PopulateTreeNode(dsList, null, &quot;0&quot;);
}

private void PopulateTreeNode(DataSet dsList, TreeNode parent, string parentID)
{
    TreeNodeCollection baseNodes;
    string rowID;
    TreeNode node;

    if (parent == null)
    {
        baseNodes = myTreeView.Nodes;
    }
    else
    {
        baseNodes = parent.ChildNodes;
    }

    foreach (DataRow dsRow in dsList.Tables&#x5B;0].Select(&quot;ParentID = &quot; + parentID))
    {
        node = new TreeNode();
        node.Text = dsRow&#x5B;&quot;Name&quot;].ToString();
        rowID = dsRow&#x5B;&quot;ID&quot;].ToString();
        node.Value = rowID;
        node.SelectAction = TreeNodeSelectAction.Select;

        // Add link back to itself so selected group could be changed
        node.NavigateUrl = &quot;~/default.aspx?id=&quot; + rowID;
        baseNodes.Add(node);

        // Use recusion to populate child nodes
        PopulateTreeNode(dsList, node, rowID);

        // Preselect the node for current group
        if (node.Value == Request.QueryString&#x5B;&quot;id&quot;])
        {
            node.Selected = true;
        }
    }
}
</pre>
<hr/><span style="font-size: 7pt">Copyright &copy; 2026 <strong><a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a></strong>. This Feed is for personal non-commercial use only.</span><p>The post <a href="https://blog.dragonsoft.us/2008/10/28/populate-treeview-from-table-in-aspnet/">Populate TreeView from table in ASP.Net</a> appeared first on <a href="https://blog.dragonsoft.us">Dragonsoft Technology View</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.dragonsoft.us/2008/10/28/populate-treeview-from-table-in-aspnet/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">545</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Minified using Disk
Database Caching 15/87 queries in 0.284 seconds using Disk

Served from: blog.dragonsoft.us @ 2026-04-22 09:58:35 by W3 Total Cache
-->