<feed xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US">
    <title>Michael Freidgeim's Blog</title>
    <link rel="self" type="application/xml" href="http://geekswithblogs.net/mnf/Atom.aspx" />
    <subtitle type="html">MS .Net Development</subtitle>
    <id>http://geekswithblogs.net/mnf/Default.aspx</id>
    <author>
        <name>Michael Freidgeim</name>
        <uri>http://geekswithblogs.net/mnf/Default.aspx</uri>
    </author>
    <generator uri="http://subtextproject.com" version="Subtext Version 0.0.0.0">Subtext</generator>
    <updated>2009-09-26T20:22:55Z</updated>
    <entry>
        <title> "The project type is not supported by this installation" for Workflow project</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/09/26/the-project-type-is-not-supported-by-this-installation.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/09/26/the-project-type-is-not-supported-by-this-installation.aspx</id>
        <published>2009-09-26T20:22:55-05:00:00</published>
        <updated>2009-09-26T20:22:55Z</updated>
        <content type="html">Download from &lt;a id="d.ar" title="ActivityExecutionContext in Workflows" goog_docs_charindex="96" href="http://msdn.microsoft.com/en-us/magazine/cc163414.aspx"&gt;ActivityExecutionContext in Workflows&lt;/a&gt;
&lt;div goog_docs_charindex="136"&gt;caused  &lt;font color="#ff0000"&gt;"The project type is not supported by this installation"&lt;/font&gt; when opened the solution.&lt;/div&gt;
&lt;div goog_docs_charindex="228"&gt;On my machine I have Workflow only for VS 2008, but not for VS 2005, but the download solution was in 2005 format.&lt;/div&gt;
&lt;div goog_docs_charindex="228"&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="344"&gt;I've explicitely started VS 2008 and then converted solution from 2005 to 2008. Error disappeared. &lt;/div&gt;
&lt;div goog_docs_charindex="445"&gt;Similar problem with Moral: If you are trying to develop with .NET 3.0 maybe it’s a good idea to check that .NET 3.0 is installed first... described &lt;a id="peeq" title="here" goog_docs_charindex="595" href="http://clintcherry.spaces.live.com/Blog/cns!AEC0DCBC460E45B9!402.entry"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/135117.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/135117.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/135117.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/135117.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Using of Workflow Dependency properties.</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/09/25/using-of-workflow-dependency-properties.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/09/25/using-of-workflow-dependency-properties.aspx</id>
        <published>2009-09-25T22:18:28-05:00:00</published>
        <updated>2009-09-25T22:40:21Z</updated>
        <content type="html">&lt;div goog_docs_charindex="47" align="left"&gt;&lt;font size="1" goog_docs_charindex="48"&gt;In our Workflow application it was created a lot of  Workflow level Dependency properties that was used  to interchange data between different activities.&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="205" align="left"&gt;&lt;font size="1" goog_docs_charindex="206"&gt;    Workflow.PropertyA=  Activity1.PropertyA&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="253" align="left"&gt;
&lt;div goog_docs_charindex="254" align="left"&gt;&lt;font size="1" goog_docs_charindex="255"&gt;    Activity2.PropertyA=Workflow.PropertyA&lt;/font&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div goog_docs_charindex="301" align="left"&gt;&lt;font size="1" goog_docs_charindex="302"&gt;We believed that is a safe way to avoid concurrency problems. But it was WRONG.&lt;br /&gt;
&lt;/font&gt;&lt;font size="1" goog_docs_charindex="385"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="389" align="left"&gt;&lt;font size="1" goog_docs_charindex="390"&gt;Article&lt;/font&gt; &lt;a id="zca0" title="ActivityExecutionContext in Workflows" goog_docs_charindex="400" href="http://msdn.microsoft.com/en-us/magazine/cc163414.aspx"&gt;ActivityExecutionContext in Workflows&lt;/a&gt;&lt;font size="1" goog_docs_charindex="439"&gt; explains, that &lt;font color="#000000" goog_docs_charindex="456"&gt;&lt;font style="BACKGROUND-COLOR: #ff0000" goog_docs_charindex="457"&gt;Workflow properties as a shared data between activities&lt;/font&gt; is not a safe method and can cause concurrency errors in case of CAG or similar usage.&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="604" align="left"&gt;&lt;font color="#000000" size="1" goog_docs_charindex="610"&gt;Best solution is to use custom activities Dependency properties and &lt;font style="BACKGROUND-COLOR: #00ff00"&gt;direct binding between activities&lt;/font&gt;.&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="715" align="left"&gt;&lt;font color="#000000" size="1" goog_docs_charindex="719"&gt;Activity2.PropertyA=  Activity1.PropertyA&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="763" align="left"&gt;&lt;font size="1" goog_docs_charindex="764"&gt; &lt;/font&gt;&lt;/div&gt;
&lt;font size="1" goog_docs_charindex="768"&gt;
&lt;div dir="ltr" class="title" goog_docs_charindex="769" align="left"&gt;The same is explained in &lt;a id="jala" title="&amp;quot;Pro WF: Windows Workflow in .NET 3.5&amp;quot; By Bruce Bukovics" goog_docs_charindex="795" href="http://books.google.com/books?id=8xqvZrym4E0C&amp;amp;pg=PA80&amp;amp;lpg=PA80&amp;amp;dq=dependency+property+workflow+activity+vs+property&amp;amp;source=bl&amp;amp;ots=ji1lmliwnI&amp;amp;sig=77m2S-VA6hmANpMkWDm6B0Kaq8U&amp;amp;hl=all&amp;amp;ei=K2O6SrTICdiCkQXFi-DuBQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=6#v=onepage&amp;amp;q=&amp;amp;f=false"&gt;"Pro WF: Windows Workflow in .NET 3.5" By Bruce Bukovics&lt;/a&gt;&lt;/div&gt;
&lt;/font&gt;
&lt;div dir="ltr" class="title" goog_docs_charindex="855" align="left"&gt;&lt;/div&gt;
&lt;font face="Utopia-Regular" goog_docs_charindex="856"&gt;&lt;font face="Utopia-Regular" goog_docs_charindex="857"&gt;&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr" goog_docs_charindex="858"&gt;&lt;font size="1" goog_docs_charindex="859"&gt;The primary advantage to dependency properties is that they allow binding of property values&lt;/font&gt; &lt;font size="1" goog_docs_charindex="956"&gt;to instance data at runtime. For example, you can bind the &lt;font style="BACKGROUND-COLOR: #00ff00" color="#000000" goog_docs_charindex="1016"&gt;input &lt;/font&gt;&lt;font style="BACKGROUND-COLOR: #00ff00" color="#000000" goog_docs_charindex="1024"&gt;property of one activity to an &lt;/font&gt;&lt;/font&gt;&lt;font size="1" goog_docs_charindex="1059"&gt;&lt;font style="BACKGROUND-COLOR: #00ff00" color="#000000" goog_docs_charindex="1060"&gt;output property of another&lt;/font&gt;. The actual property values resulting from the binding is determined at &lt;/font&gt;&lt;font size="1" goog_docs_charindex="1163"&gt;runtime.&lt;/font&gt; &lt;font size="1" goog_docs_charindex="1175"&gt;Dependency properties are required when you want to bind properties from one activity to &lt;/font&gt;&lt;font size="1" goog_docs_charindex="1267"&gt;another. However, if you are binding an activity property to a workflow property, the &lt;font style="BACKGROUND-COLOR: #00ff00" goog_docs_charindex="1354"&gt;workflow property &lt;/font&gt;&lt;/font&gt;&lt;font size="1" goog_docs_charindex="1376"&gt;&lt;font style="BACKGROUND-COLOR: #00ff00" goog_docs_charindex="1377"&gt;is not required to be a dependency property&lt;/font&gt;. In this case, a normal C# property on the workflow class &lt;/font&gt;&lt;font size="1" goog_docs_charindex="1483"&gt;works fine.&lt;/font&gt;&lt;/blockquote&gt;&lt;/font&gt;&lt;blockquote style="MARGIN-RIGHT: 0px" dir="ltr" goog_docs_charindex="858"&gt;&lt;/blockquote&gt;
&lt;div class="dtH1" goog_docs_charindex="1499"&gt;&lt;a id="iazs" title="Performance Characteristics of Windows Workflow Foundation" goog_docs_charindex="1500" href="http://msdn.microsoft.com/en-us/library/aa973808.aspx"&gt;&lt;font color="#810081" goog_docs_charindex="1501"&gt;Performance Characteristics of Windows Workflow Foundation&lt;/font&gt;&lt;/a&gt; tells to avoid using dependency properties if not necessary:&lt;/div&gt;
&lt;div class="dtH1" goog_docs_charindex="1624"&gt;&lt;font size="1" goog_docs_charindex="1625"&gt;A &lt;strong style="BACKGROUND-COLOR: #ffff66; COLOR: black" goog_docs_charindex="1628"&gt;dependency&lt;/strong&gt; &lt;strong style="BACKGROUND-COLOR: #a0ffff; COLOR: black" goog_docs_charindex="1641"&gt;property&lt;/strong&gt; is a powerful mechanism that helps you expose &lt;strong style="BACKGROUND-COLOR: #ff9999; COLOR: black" goog_docs_charindex="1698"&gt;activity&lt;/strong&gt; properties so they can be bound and shared within a &lt;strong style="BACKGROUND-COLOR: #99ff99; COLOR: black" goog_docs_charindex="1761"&gt;workflow&lt;/strong&gt; instance. There is a small &lt;strong style="BACKGROUND-COLOR: #00aa00; COLOR: white" goog_docs_charindex="1799"&gt;performance&lt;/strong&gt; overhead associated with this &lt;strong style="BACKGROUND-COLOR: #a0ffff; COLOR: black" goog_docs_charindex="1843"&gt;property&lt;/strong&gt; type, especially when many &lt;strong style="BACKGROUND-COLOR: #ffff66; COLOR: black" goog_docs_charindex="1881"&gt;dependency&lt;/strong&gt; properties are being accessed from the &lt;strong style="BACKGROUND-COLOR: #99ff99; COLOR: black" goog_docs_charindex="1933"&gt;workflow&lt;/strong&gt;, but in most cases the overhead should be minimal.&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="1996"&gt; &lt;/div&gt;
&lt;div goog_docs_charindex="1999"&gt;
&lt;div id="ctl00$eb1$ctl06" class="statHover" goog_docs_charindex="2000"&gt;Related links: &lt;a title="DependencyProperty Class" goog_docs_charindex="2016" href="http://msdn.microsoft.com/en-us/library/ms616401.aspx"&gt;&lt;font color="#000000" goog_docs_charindex="2017"&gt;DependencyProperty Class&lt;/font&gt;&lt;/a&gt; &lt;br goog_docs_charindex="2048" /&gt;
           &lt;a id="e5f0" title="wdp snippet" href="http://www.pluralsight.com/community/blogs/matt/archive/2006/10/25/41183.aspx"&gt;wdp snippet&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/font&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/135103.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/135103.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/135103.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/135103.aspx</trackback:ping>
    </entry>
    <entry>
        <title>LongestCommonPrefix function for 2 strings</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/09/09/longestcommonprefix-function-for-2-strings.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/09/09/longestcommonprefix-function-for-2-strings.aspx</id>
        <published>2009-09-09T23:15:33-05:00:00</published>
        <updated>2009-09-09T23:15:33Z</updated>
        <content type="html">&lt;font face=""&gt;
&lt;div style="FONT-FAMILY: Courier New; BACKGROUND: white; COLOR: black; FONT-SIZE: 10pt"&gt;
&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: green"&gt;The function that finds &lt;font face=""&gt; Common Prefix for 2 strings&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: green"&gt;//converted from http://stackoverflow.com/questions/1250514/find-length-of-initial-segment-matching-mask-on-arrays&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&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;string&lt;/span&gt; LongestCommonPrefix(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; str1, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; str2)&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;             {  &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                 &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; minLen = &lt;span style="COLOR: #2b91af"&gt;Math&lt;/span&gt;.Min(str1.Length, str2.Length);&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                 &lt;span style="COLOR: blue"&gt;for&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; i = 0; i &amp;lt; minLen; i++) &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                 {&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                     &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (str1[i] != str2[i])&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                     { &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                         &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; str1.Substring( 0, i);     &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                     }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                 }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                 &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; str1.Substring( 0, minLen);&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;             }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;!--EndFragment--&gt;&lt;/p&gt;
&lt;/font&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/134604.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/134604.aspx</wfw:comment>
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/134604.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/134604.aspx</trackback:ping>
    </entry>
    <entry>
        <title>ASP.NET Validators should be visible to do validation</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/08/23/asp.net-validators-should-be-visible-to-do-validation.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/08/23/asp.net-validators-should-be-visible-to-do-validation.aspx</id>
        <published>2009-08-23T06:41:00-05:00:00</published>
        <updated>2009-08-23T06:41:00Z</updated>
        <content type="html">&lt;div&gt;&lt;span style="FONT-SIZE: 10pt"&gt;Validators are disabled, if they are not visible. They can be not visible, if any of their containers is not visible.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="FONT-SIZE: 10pt"&gt;In general, they should be always visible, but the message will be shown only if they will be NOT valid.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="FONT-SIZE: 10pt"&gt;Also consider to set &lt;font face=""&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.setfocusonerror.aspx"&gt;BaseValidator.SetFocusOnError&lt;/a&gt;=true. &lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="FONT-SIZE: 10pt"&gt;&lt;font face=""&gt;In big pages use &lt;a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.basevalidator.validationgroup.aspx"&gt;ValidationGroup &lt;/a&gt;combined with &lt;span&gt;&lt;span class="input"&gt;CausesValidation&lt;/span&gt;&lt;/span&gt; property set to &lt;span&gt;&lt;span class="input"&gt;true.&lt;/span&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/134260.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/134260.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/134260.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/134260.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Declare local variable within the loop instead of using loop variable  in Linq methods</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/07/18/declare-local-variable-within-the-loop-if-using-loop-variable.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/07/18/declare-local-variable-within-the-loop-if-using-loop-variable.aspx</id>
        <published>2009-07-18T07:47:18-05:00:00</published>
        <updated>2009-07-18T07:49:27Z</updated>
        <content type="html">&lt;div goog_docs_charindex="1"&gt;I've noticed in my LINQ code Resharper Warning "&lt;font color="#810081" goog_docs_charindex="52"&gt;'Access to modified closure'&lt;/font&gt;". The search pointed that there is very confusing potential error.&lt;/div&gt;
&lt;div goog_docs_charindex="150"&gt;If  for/foreach loop variable is used only in Linq methods (more general, only as a parameter for delegates) , only the last value of the variable will be used for all calls.&lt;/div&gt;
&lt;div goog_docs_charindex="326"&gt;It always required to create local variable inside loop and use the local variable instead of loop variable.&lt;/div&gt;
&lt;div goog_docs_charindex="436"&gt;More about the issue: &lt;a goog_docs_charindex="459" href="http://weblogs.asp.net/fbouma/archive/2009/06/25/linq-beware-of-the-access-to-modified-closure-demon.aspx"&gt;&lt;font color="#810081" goog_docs_charindex="460"&gt;Linq: Beware of the 'Access to modified closure' demon&lt;/font&gt;&lt;/a&gt; &lt;br goog_docs_charindex="518" /&gt;
&lt;a class="question-hyperlink" goog_docs_charindex="519" href="http://stackoverflow.com/questions/271440/c-captured-variable-in-loop"&gt;&lt;font color="#810081" size="2" goog_docs_charindex="520"&gt;C# Captured Variable In Loop&lt;/font&gt;&lt;/a&gt;&lt;br goog_docs_charindex="551" /&gt;
&lt;a class="question-hyperlink" goog_docs_charindex="552" href="http://stackoverflow.com/questions/295593/linq-query-built-in-foreach-loop-always-takes-parameter-value-from-last-iteration"&gt;&lt;font color="#810081" size="2" goog_docs_charindex="553"&gt;Linq query built in foreach loop always takes parameter value from last iteration&lt;/font&gt;&lt;/a&gt;&lt;br goog_docs_charindex="637" /&gt;
Theoretical discussion, why this confusing behavior was implemented can be found in &lt;a class="l" goog_docs_charindex="718" href="http://blogs.msdn.com/abhinaba/archive/2005/10/18/482180.aspx"&gt;&lt;font size="3" goog_docs_charindex="719"&gt;&lt;font color="#2200cc" goog_docs_charindex="720"&gt;C#: &lt;strong goog_docs_charindex="755"&gt;Anonymous methods are not closures&lt;/strong&gt;&lt;/font&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="795"&gt; &lt;br goog_docs_charindex="797" /&gt;
&lt;/div&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/133571.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/133571.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/133571.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/133571.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Implement Copy constructor using Serialization or Reflecton  </title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/07/17/implement-copy-constructor-using-serialization-or-reflecton.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/07/17/implement-copy-constructor-using-serialization-or-reflecton.aspx</id>
        <published>2009-07-17T18:01:20-05:00:00</published>
        <updated>2009-08-19T07:43:39Z</updated>
        <content type="html">&lt;div goog_docs_charindex="49"&gt;Some time ago I wrote a post &lt;a id="viewpost_ascx_TitleUrl" title="Title of this entry." goog_docs_charindex="79" href="http://geekswithblogs.net/mnf/archive/2007/05/25/no-copy-constructor-support-in-.net-framework.aspx"&gt;&lt;font color="#810081" goog_docs_charindex="80"&gt;No Copy Constructor support in .Net framework.&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="130"&gt;and was adviced by &lt;a id="Comments_ascx_CommentList_ctl00_NameLink" title="http://geekswithblogs.net/thibbard/" target="_blank" goog_docs_charindex="150" href="http://geekswithblogs.net/thibbard/"&gt;Tim Hibbard&lt;/a&gt; to use &lt;a id="fquc" title="reflection like this." goog_docs_charindex="171" href="http://geekswithblogs.net/thibbard/archive/2007/05/04/Architecture-thoughts-and-Reflection.aspx"&gt;reflection like this.&lt;/a&gt;&lt;br goog_docs_charindex="194" /&gt;
&lt;/div&gt;
&lt;div goog_docs_charindex="196"&gt;I've created Copy method to copy Fields(not only properties, and found that  the private fields of any base class are not copied.&lt;/div&gt;
&lt;div goog_docs_charindex="327"&gt;The article &lt;a id="bkmk_href_0-2" title="http://agsmith.wordpress.com/2007/12/13/where-are-my-fields/" goog_docs_charindex="340" href="http://www.google.com/history/url?url=http://agsmith.wordpress.com/2007/12/13/where-are-my-fields/&amp;amp;ei=bPNgSvOBFYr2sAKksI3DCA&amp;amp;sig2=2EfV2UgRRAfR4nfXS31Ehg&amp;amp;ct=w"&gt;&lt;font color="#810081" goog_docs_charindex="341"&gt;Where are my fields? « Andrew Smith&lt;/font&gt;&lt;/a&gt; explains that it's required to iterate base classes.&lt;/div&gt;
&lt;div goog_docs_charindex="433"&gt;But when looking in the Google for the solution,I've found &lt;a id="moqz" title="the suggestion for serializable objects" goog_docs_charindex="493" href="http://stackoverflow.com/questions/469982/how-would-you-improve-this-shallow-copying-class"&gt;the suggestion for serializable objects&lt;/a&gt;:&lt;/div&gt;
&lt;div goog_docs_charindex="433"&gt; &lt;/div&gt;
&lt;div goog_docs_charindex="536"&gt;&lt;font face="Courier New" goog_docs_charindex="537"&gt;&lt;font face="Courier New" goog_docs_charindex="538"&gt;&lt;font color="#000000"&gt;&lt;font style="BACKGROUND-COLOR: #00ff00"&gt;&lt;span class="typ" goog_docs_charindex="539"&gt;MemberInfo&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="551"&gt;[]&lt;/span&gt;&lt;span class="pln" goog_docs_charindex="555"&gt; sm &lt;/span&gt;&lt;span class="pun" goog_docs_charindex="561"&gt;=&lt;/span&gt; &lt;span class="typ" goog_docs_charindex="565"&gt;FormatterServices&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="584"&gt;.&lt;/span&gt;&lt;span class="typ" goog_docs_charindex="587"&gt;GetSerializableMembers&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="611"&gt;(&lt;/span&gt;&lt;span class="kwd" goog_docs_charindex="614"&gt;typeof&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="622"&gt;(&lt;/span&gt;&lt;span class="typ" goog_docs_charindex="625"&gt;From&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="631"&gt;));&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="639"&gt;&lt;font face="Courier New" goog_docs_charindex="640"&gt;&lt;font face="Courier New" goog_docs_charindex="641"&gt;&lt;font color="#000000"&gt;&lt;font style="BACKGROUND-COLOR: #00ff00"&gt; &lt;span class="kwd" goog_docs_charindex="643"&gt;object&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="651"&gt;[]&lt;/span&gt;&lt;span class="pln" goog_docs_charindex="655"&gt; data &lt;/span&gt;&lt;span class="pun" goog_docs_charindex="663"&gt;=&lt;/span&gt; &lt;span class="typ" goog_docs_charindex="667"&gt;FormatterServices&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="686"&gt;.&lt;/span&gt;&lt;span class="typ" goog_docs_charindex="689"&gt;GetObjectData&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="704"&gt;(&lt;/span&gt;&lt;span class="kwd" goog_docs_charindex="707"&gt;from&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="713"&gt;,&lt;/span&gt;&lt;span class="pln" goog_docs_charindex="716"&gt; sm&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="721"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="728"&gt;&lt;font face="Courier New" goog_docs_charindex="729"&gt;&lt;font face="Courier New" goog_docs_charindex="730"&gt;&lt;font color="#000000"&gt;&lt;font style="BACKGROUND-COLOR: #00ff00"&gt; &lt;span class="typ" goog_docs_charindex="732"&gt;FormatterServices&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="751"&gt;.&lt;/span&gt;&lt;span class="typ" goog_docs_charindex="754"&gt;PopulateObjectMembers&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="777"&gt;(&lt;/span&gt;&lt;span class="pln" goog_docs_charindex="780"&gt;to&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="784"&gt;,&lt;/span&gt;&lt;span class="pln" goog_docs_charindex="787"&gt; sm&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="792"&gt;,&lt;/span&gt;&lt;span class="pln" goog_docs_charindex="795"&gt; data&lt;/span&gt;&lt;span class="pun" goog_docs_charindex="802"&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;p goog_docs_charindex="809"&gt; &lt;/p&gt;
&lt;div goog_docs_charindex="812"&gt;&lt;font face="Courier New" goog_docs_charindex="813"&gt;&lt;font face="Courier New" goog_docs_charindex="814"&gt;&lt;span class="pun" goog_docs_charindex="815"&gt;It seems to solve my requirement better than the reflection approach:&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="887"&gt;&lt;br goog_docs_charindex="888" /&gt;
&lt;/div&gt;
&lt;br goog_docs_charindex="890" /&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Inspired by http://geekswithblogs.net/thibbard/archive/2007/05/04/Architecture-thoughts-and-Reflection.aspx&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="from"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="from"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;        &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&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;bool&lt;/span&gt; CopyFleldsFromBaseClass(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; from,&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; to)&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;        {&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; rv = &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;            {&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (from == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                {&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    &lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ApplicationException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"from is null"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (to == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                {&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    &lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ApplicationException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"to is null"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: green"&gt;//http://agsmith.wordpress.com/2007/12/13/where-are-my-fields/&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                System.&lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; typeFrom = from.GetType();&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                System.&lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; typeTo = from.GetType();&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt; bindingFlags = &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.Instance | &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.NonPublic | &lt;span style="COLOR: #2b91af"&gt;BindingFlags&lt;/span&gt;.Public ;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: green"&gt;//Debug.Assert(typeTo is typeFrom);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: green"&gt;//iterate through each property of this&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;FieldInfo&lt;/span&gt; prop &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; typeFrom.GetFields(bindingFlags))&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                {&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    &lt;span style="COLOR: green"&gt;//get the name of the current property&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; memberName = prop.Name;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    &lt;span style="COLOR: green"&gt;//make sure this property is writeable and the obj property is readable&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    &lt;span style="COLOR: green"&gt;//if (prop.CanRead &amp;amp;&amp;amp; to.GetType().GetFields(memberName).CanWrite)&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (typeTo.GetField(memberName, bindingFlags) != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    {&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                        &lt;span style="COLOR: green"&gt;//Get the value of this current property from obj&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                        &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; objValue = typeFrom.GetField(memberName, bindingFlags).GetValue(from);&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                        &lt;span style="COLOR: green"&gt;//Set the value of this property from obj&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                        prop.SetValue(to, objValue);&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                    }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: green"&gt;//if we are here, everything worked&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                rv = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;            }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;catch&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;Exception&lt;/span&gt; exc)&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;            {&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: #2b91af"&gt;Debug&lt;/span&gt;.Assert(&lt;span style="COLOR: blue"&gt;false&lt;/span&gt;,exc.ToString());&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                &lt;span style="COLOR: green"&gt;//something bad happened, return false&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;                rv = &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;            }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;            &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; rv;&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;        }&lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;By the way, my original idea was to create a derived class, when I have on object of base class. &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;Later I understood that it's better to create the derived object using factory at the start, &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;rather than create the base class and then convert it to derived one. &lt;/pre&gt;
&lt;pre style="MARGIN: 0px"&gt;Related link on Rick Strahl's Blog    &lt;a title="In many applications it’s necessary to copy data between objects. Especially these days where we often have entities and Data Transfer Objects (DTO) where data needs to be shuttled back and forth between two objects I find it handy to have a simple routine that performs at least rudimentary, shallow data copying for me without manually having to write data mapping code at least if the properties identically or nearly identically. A few days ago I had a lengthy discussion about this topic on Twitter as well and some suggestions that some sort of data copying mechanism should be built into the..." onclick="_IG_FRUC_setFeedAsRead(103,1)" href="http://feedproxy.google.com/~r/RickStrahl/~3/yWwem6d3epw/847436.aspx"&gt;Simplistic Object Copying in .NET&lt;/a&gt; &lt;/pre&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/133565.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/133565.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/133565.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/133565.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Text from SQL Management Studio reformatted by Google Docs when using IE.</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/07/04/text-from-sql-management-studio-reformatted-in-google-docs-by.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/07/04/text-from-sql-management-studio-reformatted-in-google-docs-by.aspx</id>
        <published>2009-07-04T07:46:18-05:00:00</published>
        <updated>2009-07-04T21:07:11Z</updated>
        <content type="html">&lt;div&gt;When I am using Google Docs, quite often I am copying the portion of code  from Visual Studio or SQL Management Studio.&lt;/div&gt;
&lt;div&gt;but the text is reformatted to become messy.&lt;/div&gt;
&lt;div&gt;E.G.&lt;/div&gt;
&lt;div style="MARGIN-LEFT: 40px"&gt; ALTER PROCEDURE [dbo].[CheckNotProcessed]&lt;br /&gt;
    @limit int = 10&lt;br /&gt;
AS&lt;br /&gt;
&lt;br /&gt;
declare @StartDate datetime&lt;br /&gt;
declare @EndDate  datetime&lt;br /&gt;
declare @NotProcessedCount int&lt;/div&gt;
&lt;div&gt;is shown as &lt;/div&gt;
&lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt;
&lt;p&gt;ALTER&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;PROCEDURE&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; [dbo]&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[CheckNotProcessed]&lt;/font&gt;&lt;/p&gt;
&lt;font size="2"&gt;
&lt;p&gt;@limit &lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt; &lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 10&lt;/font&gt;&lt;/p&gt;
&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;AS&lt;/p&gt;
&lt;p&gt;declare&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;&lt;font size="2"&gt;@StartDate &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;datetime&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;declare&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;&lt;font size="2"&gt;@EndDate &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;datetime&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;declare&lt;/p&gt;
&lt;/font&gt;
&lt;p&gt; &lt;/p&gt;
&lt;/font&gt;
&lt;p&gt;&lt;font size="2"&gt;@NotProcessedCount &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt; &lt;/p&gt;
&lt;/blockquote&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;I've tried to manually insert in HTML view &amp;lt;PRE&amp;gt;&amp;lt;/PRE&amp;gt; tags and then paste text between tags.&lt;/div&gt;
&lt;div&gt;But  in "Edit Html" under IE7  I am not able to "Update" - it causes JavaScript &lt;font color="#0000ff"&gt; &lt;/font&gt;&lt;font color="#000000"&gt;"Invalid Argument" error.&lt;br /&gt;
&lt;br /&gt;
&lt;/font&gt;&lt;font color="#000000"&gt;In Firefox I can paste the plain text&lt;/font&gt;&lt;font color="#000000"&gt;. &lt;br /&gt;
Unfortunately, it doesn't have syntax colours, that I would like to preserve from SQL Management Studio.&lt;/font&gt;&lt;/div&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/133254.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/133254.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/133254.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/133254.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Custom alert on the SQL Database </title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/07/04/custom-alert-on-the-sql-database.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/07/04/custom-alert-on-the-sql-database.aspx</id>
        <published>2009-07-04T07:07:36-05:00:00</published>
        <updated>2009-07-04T07:23:30Z</updated>
        <content type="html">&lt;div&gt; I wanted to create a custom alert on the &lt;span class="misspell" suggestions="SQ,SAL,SOL,SQQ,SQ'S"&gt;SQL&lt;/span&gt; Database when number of records with some values(considered as invalid) exceeds the expected limit. &lt;/div&gt;
&lt;div&gt;&lt;br /&gt;
First of all you need to &lt;font size="3"&gt;&lt;a id="bbbg" title="Setting up Database Mail for SQL 2005" href="http://www.mssqltips.com/tip.asp?tip=1100"&gt;&lt;strong&gt;Set up Database Mail for &lt;span class="misspell" suggestions="SQ,SAL,SOL,SQQ,SQ'S"&gt;SQL&lt;/span&gt; 2005&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;and follow procedure&lt;/font&gt;&lt;br /&gt;
&lt;/div&gt;
&lt;div&gt;&lt;a class="l" href="http://www.mssqltips.com/tip.asp?tip=1523"&gt;&lt;font color="#2200cc" size="3"&gt;How to setup &lt;strong&gt;&lt;span class="misspell" suggestions="SQ,SAL,SOL,SQQ,SQ'S"&gt;SQL&lt;/span&gt; Server alerts&lt;/strong&gt; and email &lt;strong&gt;operator&lt;/strong&gt; &lt;span class="misspell" suggestions="notifications,notification's,notification,pontifications,fortifications"&gt;notifications&lt;/span&gt;&lt;/font&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;IMPORTANT: don't forget to &lt;strong&gt;Restart &lt;span class="misspell" suggestions="SQ,SAL,SOL,SQQ,SQ'S"&gt;SQL&lt;/span&gt; Agent to activate settings. &lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Similar to the article &lt;a title="Permanent Link: Define custom error messages in SQL Server 2005" rel="bookmark" href="http://blogs.techrepublic.com.com/datacenter/?p=390"&gt;&lt;font color="#810081"&gt;Define custom error messages in &lt;span class="misspell" suggestions="SQ,SAL,SOL,SQQ,SQ'S"&gt;SQL&lt;/span&gt; Server 2005&lt;/font&gt;&lt;/a&gt;&lt;br /&gt;
I've defined the error&lt;br /&gt;
&lt;font face="Courier New"&gt;EXEC &lt;span class="misspell" suggestions="Sp,SOP,Sep,sap,sip"&gt;sp&lt;/span&gt;_&lt;span class="misspell" suggestions="add message,add-message,Addams,Adams,Adm's"&gt;addmessage&lt;/span&gt; 60001, 1, &lt;span class="misspell" suggestions="Number,Renumber,Numbers,Umber,Numbed"&gt;N'&lt;/span&gt;&lt;/font&gt;Number of not-processed  tasks %d exceed the limit on %s.'&lt;br /&gt;
and SP:&lt;br /&gt;
 &lt;/div&gt;
&lt;div&gt;
&lt;table class="" id="d5m7" bordercolor="#000000" cellspacing="0" cellpadding="3" width="100%" border="1"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td width="100%"&gt;
            &lt;pre&gt;ALTER PROCEDURE [&lt;span class="misspell" suggestions="DOB,dob,dB,db,BO"&gt;dbo&lt;/span&gt;].[&lt;span class="misspell" suggestions=""&gt;CheckNotProcessed&lt;/span&gt;]
	@limit int = 10
AS

declare @&lt;span class="misspell" suggestions="Start Date,Start-Date,Statute,Stardust,Started"&gt;StartDate&lt;/span&gt; &lt;span class="misspell" suggestions="date time,date-time,daytime,teatime,downtime"&gt;datetime&lt;/span&gt;
declare @&lt;span class="misspell" suggestions="End Date,End-Date,Indite,Ended,Endeared"&gt;EndDate&lt;/span&gt;  &lt;span class="misspell" suggestions="date time,date-time,daytime,teatime,downtime"&gt;datetime&lt;/span&gt;
declare @&lt;span class="misspell" suggestions=""&gt;NotProcessedCount&lt;/span&gt; int
set @&lt;span class="misspell" suggestions="End Date,End-Date,Indite,Ended,Endeared"&gt;EndDate&lt;/span&gt;  =&lt;span class="misspell" suggestions="Get Date,Get-Date,Gestate,Gradate,Gestated"&gt;GetDate&lt;/span&gt;()&lt;br /&gt;set @&lt;span class="misspell" suggestions="Start Date,Start-Date,Statute,Stardust,Started"&gt;StartDate&lt;/span&gt; =&lt;span class="misspell" suggestions="DATE ADD,DATE-ADD,DATED,DARTED,DOTED"&gt;DATEADD&lt;/span&gt; (day ,-1, @&lt;span class="misspell" suggestions="End Date,End-Date,Indite,Ended,Endeared"&gt;EndDate&lt;/span&gt;) 
print @&lt;span class="misspell" suggestions="Start Date,Start-Date,Statute,Stardust,Started"&gt;StartDate&lt;/span&gt;
print @&lt;span class="misspell" suggestions="End Date,End-Date,Indite,Ended,Endeared"&gt;EndDate&lt;/span&gt;

	select @&lt;span class="misspell" suggestions=""&gt;NotProcessedCount&lt;/span&gt;=count(*) from &lt;span class="misspell" suggestions="DOB,dob,dB,db,BO"&gt;dbo&lt;/span&gt;.[&lt;span class="misspell" suggestions="Mutable,Mutably,Metal,Motel,Mattel"&gt;MyTBL&lt;/span&gt;]
where [&lt;span class="misspell" suggestions="Process State,Process-State,Prostate,Processed,Precipitate"&gt;ProcessState&lt;/span&gt;] &amp;lt;&amp;gt; 99999
and &lt;span class="misspell" suggestions="created Date,created-Date,created,cremated,crested"&gt;createdDate&lt;/span&gt; between @&lt;span class="misspell" suggestions="Start Date,Start-Date,Statute,Stardust,Started"&gt;StartDate&lt;/span&gt; and @&lt;span class="misspell" suggestions="End Date,End-Date,Indite,Ended,Endeared"&gt;EndDate&lt;/span&gt;

if( @&lt;span class="misspell" suggestions=""&gt;NotProcessedCount&lt;/span&gt;&amp;gt;@limit)
begin
declare @&lt;span class="misspell" suggestions=""&gt;CurrentDBName&lt;/span&gt;  &lt;span class="misspell" suggestions="var char,var-char,watcher,Archer,archer"&gt;varchar&lt;/span&gt;(60)
set @&lt;span class="misspell" suggestions=""&gt;CurrentDBName&lt;/span&gt;=DB_NAME()
  &lt;span class="misspell" suggestions="RAISER,RAISERS,RAISER'S,ROISTERER,RAISE"&gt;RAISERROR&lt;/span&gt;  (60001, 10,1,@NotProcessedCount, @&lt;span class="misspell" suggestions=""&gt;CurrentDBName&lt;/span&gt;) WITH LOG
END
/*
-- =============================================
-- Example to execute the stored procedure
-- =============================================
EXECUTE &lt;span class="misspell" suggestions="DOB,DB,BO,DO,DBL"&gt;DBO&lt;/span&gt;.&lt;span class="misspell" suggestions=""&gt;CheckNotProcessed&lt;/span&gt; 10
*/
&lt;/pre&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;
Note that if you have more than one similar database on the same server, it's important to specify  &lt;font face="Courier New"&gt;DB_NAME()&lt;br /&gt;
&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;I've also created Job to call the SP on a regular basis.&lt;br /&gt;
Then I've&lt;a class="l" href="http://msdn.microsoft.com/en-us/library/aa176957%28SQL.80%29.aspx"&gt;&lt;font color="#2200cc" size="3"&gt; created an &lt;strong&gt;alert&lt;/strong&gt; using an error &lt;strong&gt;number&lt;/strong&gt; (Enterprise Manager)&lt;/font&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I &lt;span class="misspell" suggestions="fouled,fold,foiled,Gould,foulard"&gt;fould&lt;/span&gt; that this approach is very powerful and allow to send monitor regular business &lt;span class="misspell" suggestions="processes,princesses,processors,processed,precises"&gt;pricesses&lt;/span&gt;, as well as get &lt;span class="misspell" suggestions="notifications,notification's,notification,pontifications,fortifications"&gt;notifications&lt;/span&gt; about some  data conditions, that required &lt;span class="misspell" suggestions="investigation,investigations,investigating,instigation,investigation's"&gt;investigation&lt;/span&gt;/debugging.&lt;/div&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/133253.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/133253.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/133253.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/133253.aspx</trackback:ping>
    </entry>
    <entry>
        <title>MSbuild Task FileUpdate to replace content in text files</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/07/03/msbuild-task-to-replace-content-in-text-files.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/07/03/msbuild-task-to-replace-content-in-text-files.aspx</id>
        <published>2009-07-03T20:45:55-05:00:00</published>
        <updated>2009-07-25T08:04:02Z</updated>
        <content type="html">&lt;p goog_docs_charindex="55"&gt;I wanted to replace some strings in files using my deployment MSbuild script. &lt;/p&gt;
&lt;p goog_docs_charindex="135"&gt;I've noticed that &lt;a id="m60v" title="MSBuild Community Tasks" goog_docs_charindex="154" href="http://msbuildtasks.tigris.org/"&gt;MSBuild Community Tasks&lt;/a&gt; Project has RegexReplace task. &lt;/p&gt;
&lt;p goog_docs_charindex="212"&gt;But when I've looked in documentation  &lt;/p&gt;
&lt;p goog_docs_charindex="253"&gt;(By the way, &lt;a id="uzb-" title="it will be good if Reference help will be available online" goog_docs_charindex="267" href="http://msbuildtasks.tigris.org/issues/show_bug.cgi?id=105"&gt;it will be good if Reference help will be available online&lt;/a&gt;, not only from download) &lt;/p&gt;
&lt;p goog_docs_charindex="354"&gt;I've realized that the task is applicable for strings(e.g file names) not to content within a file. &lt;/p&gt;
&lt;p goog_docs_charindex="456"&gt;Almost accidently in &lt;a id="deb-" title="one of the post" goog_docs_charindex="478" href="http://msbuildtasks.tigris.org/ds/viewMessage.do?dsForumId=4391&amp;amp;dsMessageId=975900&amp;amp;orderBy=createDate&amp;amp;orderType=desc"&gt;one of the post&lt;/a&gt;s i've found a reference to FileUpdate&lt;br goog_docs_charindex="815" /&gt;
task, that support Regex and does content replacements within a file. &lt;/p&gt;
&lt;p goog_docs_charindex="524"&gt;The following examle (from downloaded help) search for a version number and update the revision. &lt;/p&gt;
&lt;div class="code" goog_docs_charindex="579"&gt;
&lt;table class="zeroBorder" cellspacing="0" cellpadding="0" width="100%" goog_docs_charindex="580"&gt;
    &lt;tbody goog_docs_charindex="581"&gt;
        &lt;tr goog_docs_charindex="582"&gt;
            &lt;th goog_docs_charindex="583"&gt; &lt;/th&gt;
            &lt;th goog_docs_charindex="586"&gt;&lt;span class="copyCode" goog_docs_charindex="587"&gt;&lt;/span&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr goog_docs_charindex="602"&gt;
            &lt;td colspan="2" goog_docs_charindex="603"&gt;
            &lt;pre goog_docs_charindex="604"&gt;            &amp;lt;FileUpdate Files="version.txt"
                Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
                ReplacementText="$1.$2.$3.123" /&amp;gt;
&lt;/pre&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;Note: don't forget to insert in to your project&lt;/p&gt;
&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;&amp;lt;&lt;/p&gt;
&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;MSBuildCommunityTasksPath&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &amp;gt;&lt;/font&gt;&lt;font size="2"&gt;.&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;MSBuildCommunityTasksPath&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&amp;gt;&lt;br /&gt;
&amp;lt;&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;Import&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; &lt;/font&gt;&lt;font color="#ff0000" size="2"&gt;Project&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;=&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;MSBuild.Community.Tasks.Targets&lt;/font&gt;&lt;font size="2"&gt;"&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; /&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;/font&gt;You may require to change &lt;font color="#a31515" size="2"&gt;MSBuildCommunityTasksPath&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt; if it is not in current directory.&lt;/font&gt;&lt;br goog_docs_charindex="745" /&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/133243.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/133243.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/133243.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/133243.aspx</trackback:ping>
    </entry>
    <entry>
        <title>MSDN documentation -methods that have corresponding operators shouldn't be called directly</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/06/19/msdn-documentation--methods-that-have-corresponding-operators-shouldnt-be-called.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/06/19/msdn-documentation--methods-that-have-corresponding-operators-shouldnt-be-called.aspx</id>
        <published>2009-06-19T20:02:10-05:00:00</published>
        <updated>2009-06-19T20:21:21Z</updated>
        <content type="html">&lt;div goog_docs_charindex="87"&gt;In our old code I'vew noticed a few examples of code like the following:&lt;/div&gt;
&lt;div goog_docs_charindex="161"&gt; MyFortune = Decimal.Add(MyFortune, .01m);&lt;br goog_docs_charindex="204" /&gt;
&lt;/div&gt;
&lt;div goog_docs_charindex="206"&gt;I was wandered, why they didn't use "+" sign, and didn't find any explanation.&lt;br goog_docs_charindex="285" /&gt;
The &lt;a id="bg8o" title="MSDN reference documentation" goog_docs_charindex="290" href="http://msdn.microsoft.com/en-us/library/system.decimal_members.aspx"&gt;MSDN reference documentation&lt;/a&gt; doesn't explain, that methods like &lt;a id="do-5" title="Add" goog_docs_charindex="356" href="http://msdn.microsoft.com/en-us/library/system.decimal.add.aspx"&gt;Add&lt;/a&gt;, &lt;a id="ctl00_MTContentSelector1_mainContentContainer_ctl72" goog_docs_charindex="363" href="http://msdn.microsoft.com/en-us/library/system.decimal.subtract.aspx"&gt;&lt;font color="#0033cc" goog_docs_charindex="364"&gt;Subtract&lt;/font&gt;&lt;/a&gt;,&lt;a id="ctl00_MTContentSelector1_mainContentContainer_ctl73" goog_docs_charindex="376" href="http://msdn.microsoft.com/en-us/library/system.decimal.multiply.aspx"&gt;&lt;font color="#0033cc" goog_docs_charindex="377"&gt;Multiply,&lt;/font&gt;&lt;/a&gt;&lt;a id="ctl00_MTContentSelector1_mainContentContainer_ctl74" goog_docs_charindex="389" href="http://msdn.microsoft.com/en-us/library/system.decimal.divide.aspx"&gt;&lt;font color="#0033cc" goog_docs_charindex="390"&gt;Divide&lt;/font&gt;&lt;/a&gt; usually should not be called explicitely. &lt;/div&gt;
&lt;div goog_docs_charindex="443"&gt;Instead of using Add method it's simpler to use + sign ( &lt;a href="http://msdn.microsoft.com/en-us/library/system.decimal.op_addition.aspx"&gt;Addition Operator&lt;/a&gt; ).&lt;br goog_docs_charindex="594" /&gt;
E.g.&lt;br goog_docs_charindex="599" /&gt;
    MyFortune = Decimal.Add(MyFortune, .01m);&lt;br goog_docs_charindex="645" /&gt;
can be rewritten as  &lt;br goog_docs_charindex="667" /&gt;
    MyFortune += .01m;&lt;/div&gt;
&lt;p goog_docs_charindex="691"&gt;Comment like this should be added to all methods, that have corresponding operators.&lt;/p&gt;
&lt;p goog_docs_charindex="691"&gt;I've posted a suggestion to &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=468559"&gt;MS Feedback&lt;/a&gt;&lt;/p&gt;
&lt;br goog_docs_charindex="776" /&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/132946.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/132946.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/132946.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/132946.aspx</trackback:ping>
    </entry>
    <entry>
        <title>DNN ability to 'Publish Web Site' </title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/06/19/dnn-ability-to-publish-web-site.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/06/19/dnn-ability-to-publish-web-site.aspx</id>
        <published>2009-06-19T19:47:46-05:00:00</published>
        <updated>2009-06-19T19:47:46Z</updated>
        <content type="html">3 years ago I've posted a workaround regarding DNN
&lt;table class="zeroBorder" cellspacing="0" cellpadding="0" width="100%" border="0" valign="top"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td class="Forum_PostDetails_Alt" valign="top" align="left" width="100%"&gt;&lt;a href="http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/-1/threadid/14873/scope/posts/Default.aspx"&gt;&lt;span class="Forum_NormalBold" id="spSubject"&gt;BUG App_GlobalResources and 'Publish Web Site' in VS2005&lt;/span&gt; &lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td class="Forum_PostButtons_Alt" valign="top" align="left"&gt; &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;a id="ccyr" title="The issue" href="http://support.dotnetnuke.com/issue/ViewIssue.aspx?p=0&amp;amp;id=2504"&gt;The issue&lt;/a&gt; is still not resolved and I recently received an email&lt;/div&gt;
&lt;div&gt;&lt;blockquote style="MARGIN-RIGHT: 0px"&gt;
&lt;p&gt;I would like to thank you a lot for your post on a DNN forum which explain how to use DNN in precompiled mode.&lt;/p&gt;
&lt;p&gt;( AppGlobalRessources...... )&lt;/p&gt;
&lt;p&gt;T H A N K S !!!!!!!!!!&lt;/p&gt;
&lt;/blockquote&gt; I am glad that the workaround is still useful, but DNN team should create a new version(even with breaking changes)&lt;/div&gt;
&lt;br /&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/132945.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/132945.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/132945.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/132945.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Scheduled Tasks tool should validate username/password combination </title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/06/13/scheduled-tasks-tool-should-validate-usernamepassword-combination.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/06/13/scheduled-tasks-tool-should-validate-usernamepassword-combination.aspx</id>
        <published>2009-06-13T14:18:55-05:00:00</published>
        <updated>2009-06-13T14:18:55Z</updated>
        <content type="html">&lt;p&gt;&lt;font face="Arial"&gt;&lt;a href="http://support.microsoft.com/default.aspx/kb/308569"&gt;Schedule Tasks in Windows  &lt;/a&gt;required to specify username and password. However it doesn't verify that the combination is correct.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="Arial"&gt;Scheduled Tasks tool should have an option to verify username/password combination and this validation should be forced when user saved(clicked OK) the task.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;I've noticed the issue on Windows 2003 server. Not sure, is it implemented on newer windows versions.&lt;/p&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/132792.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/132792.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/132792.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/132792.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Do not check-in DEBUG specific code.</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/06/13/do-not-check-in-debug-specific-code.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/06/13/do-not-check-in-debug-specific-code.aspx</id>
        <published>2009-06-13T02:34:12-05:00:00</published>
        <updated>2009-06-20T02:55:28Z</updated>
        <content type="html">&lt;div goog_docs_charindex="43"&gt;We are using .Net Remoting to interact beteeen client and back end server. I needed to call a method from services class.&lt;/div&gt;
&lt;div goog_docs_charindex="166"&gt;For debugging purposes I decided to create the class directly. It was easier to debug without starting extra back-end process.&lt;/div&gt;
&lt;div goog_docs_charindex="294"&gt;The code was like the following:&lt;/div&gt;
&lt;div goog_docs_charindex="328"&gt;
&lt;p goog_docs_charindex="329"&gt;&lt;font color="#2b91af" size="2" goog_docs_charindex="330"&gt;&lt;font color="#2b91af" size="2" goog_docs_charindex="331"&gt;IMyServices &lt;/font&gt;&lt;/font&gt;&lt;font size="2" goog_docs_charindex="346"&gt;services = (&lt;/font&gt;&lt;font color="#2b91af" size="2" goog_docs_charindex="360"&gt;&lt;font color="#000000" size="2" goog_docs_charindex="361"&gt;IMyServices&lt;/font&gt;&lt;/font&gt;&lt;font size="2" goog_docs_charindex="375"&gt;)&lt;/font&gt;&lt;font color="#2b91af" size="2" goog_docs_charindex="378"&gt;&lt;font color="#2b91af" size="2" goog_docs_charindex="379"&gt;RemotingHelper&lt;/font&gt;&lt;/font&gt;&lt;font size="2" goog_docs_charindex="396"&gt;.GetObject(&lt;/font&gt;&lt;font color="#0000ff" size="2" goog_docs_charindex="409"&gt;&lt;font color="#0000ff" size="2" goog_docs_charindex="410"&gt;typeof&lt;/font&gt;&lt;/font&gt;&lt;font size="2" goog_docs_charindex="419"&gt;(&lt;/font&gt;&lt;font color="#2b91af" size="2" goog_docs_charindex="422"&gt;&lt;font color="#000000" size="2" goog_docs_charindex="423"&gt;IMyServices&lt;/font&gt;&lt;/font&gt;&lt;font size="2" goog_docs_charindex="437"&gt;));&lt;br /&gt;
&lt;/font&gt;&lt;font color="#0000ff" size="2" goog_docs_charindex="443"&gt;&lt;font color="#0000ff" size="2" goog_docs_charindex="444"&gt;#if &lt;font size="2" goog_docs_charindex="455"&gt;DEBUG&lt;br /&gt;
&lt;/font&gt;&lt;font size="2" goog_docs_charindex="463"&gt;    services = &lt;font color="#0000ff" size="2" goog_docs_charindex="484"&gt;&lt;font color="#0000ff" size="2" goog_docs_charindex="485"&gt;new&lt;/font&gt;&lt;/font&gt; &lt;font color="#2b91af" size="2" goog_docs_charindex="492"&gt;&lt;font color="#2b91af" size="2" goog_docs_charindex="493"&gt;MyServices&lt;/font&gt;&lt;/font&gt;&lt;font size="2" goog_docs_charindex="506"&gt;();&lt;br /&gt;
&lt;/font&gt;&lt;font color="#0000ff" size="2" goog_docs_charindex="512"&gt;&lt;font color="#0000ff" size="2" goog_docs_charindex="513"&gt;#endif&lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font color="#008000" size="2" goog_docs_charindex="525"&gt;&lt;font color="#008000" size="2" goog_docs_charindex="526"&gt;// Process the task&lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font size="2" goog_docs_charindex="549"&gt;services.&lt;font color="#008000" goog_docs_charindex="560"&gt;Process&lt;/font&gt;Items(ItemsCollection);&lt;/font&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;During the development I checked that the method done the required processing and changed the parameter object as expected.&lt;/p&gt;
&lt;/div&gt;
&lt;div goog_docs_charindex="721"&gt;And I've checked in the code, assuming that in Release mode the application will work the same way just by instantiating proxy instead of full object.&lt;/div&gt;
&lt;div goog_docs_charindex="873"&gt;However in Release mode changes in parameter inside calling method were not returned back.&lt;/div&gt;
&lt;div goog_docs_charindex="965"&gt;Of course, &lt;a id="d5s9" title="If parameter is serializable, it is passed by value." goog_docs_charindex="977" href="http://geekswithblogs.net/mnf/archive/2008/05/10/passing-parameters-in-.net-remoting.aspx"&gt;If parameter is serializable, it is passed by value.&lt;/a&gt; and correct implementation will use return value&lt;/div&gt;
&lt;div goog_docs_charindex="1081"&gt;
&lt;p goog_docs_charindex="1082"&gt; ItemsCollection = services.&lt;font color="#008000" goog_docs_charindex="1113"&gt;Process&lt;/font&gt;Items(ItemsCollection);&lt;/p&gt;
&lt;p goog_docs_charindex="1146"&gt;But more general recommendation before check-in remove/comment-out any DEBUG specific shortcuts and test the code  as it will be in production.&lt;/p&gt;
&lt;br goog_docs_charindex="1291" /&gt;
&lt;/div&gt;
&lt;br goog_docs_charindex="1293" /&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/132785.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/132785.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/132785.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/132785.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Call eventTimer_Elapsed method asyncronoulsy OnStart of Windows Service</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/06/07/call-eventtimer_elapsed-method-asyncronoulsy-onstart-of-windows-service.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/06/07/call-eventtimer_elapsed-method-asyncronoulsy-onstart-of-windows-service.aspx</id>
        <published>2009-06-07T03:41:05-05:00:00</published>
        <updated>2009-06-07T08:12:22Z</updated>
        <content type="html">&lt;div&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;We have   &lt;strong&gt;&lt;font color="#000000"&gt;eventTimer in Windows Service&lt;/font&gt;&lt;/strong&gt;  (similar as described in  &lt;a id="d0sm" title="Timer Objects in Windows Services with C#.NET" href="http://www.aspfree.com/c/a/C-Sharp/Timer-Objects-in-Windows-Services-with-C-sharp-dot-NET/"&gt;&lt;font color="#810081" size="2"&gt;Timer Objects in Windows Services with C#.NET&lt;/font&gt;&lt;/a&gt; &lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;and &lt;font color="#000000"&gt;&lt;a id="u1nz" title="Using Timers in a Windows Service" href="http://www.codeguru.com/columns/dotnet/article.php/c6919"&gt;Using Timers in a Windows Service&lt;/a&gt;&lt;/font&gt;) &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;to run the  relatively long-running process repeatedly.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font color="#0000ff"&gt;NOTE:&lt;a href="http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx"&gt; &lt;font style="BACKGROUND-COLOR: #ff9900"&gt;It is NOT a good idea &lt;/font&gt;&lt;/a&gt;&lt;/font&gt;&lt;font color="#000000"&gt;&lt;font style="BACKGROUND-COLOR: #ff9900"&gt;&lt;a href="http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx"&gt;to Use a Windows Service just to run a scheduled process&lt;/a&gt;&lt;/font&gt;, but I have to maintain a legacy application, that was written as a Windows Service .&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;The process called each time when eventTimer_Elapsed. But I want to run it immediately(not to wait until timer will elapsed)  when service started or Continued.&lt;/div&gt;
&lt;div&gt;However I wanted to call it asynchronously from OnStart method, because otherwise Start command seems to hang until process is finished.&lt;/div&gt;
&lt;div&gt;Thanks to asyncronous calls for delegates, I 've created a function to invoke eventTimer_Elapsed from any place asyncronously and my service has the following methods:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;font color="#0000ff"&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; BeginInvokeElapsedEvent(&lt;font color="#0000ff"&gt;object&lt;/font&gt; sender, &lt;font color="#2b91af"&gt;ElapsedEventArgs&lt;/font&gt; e)&lt;br /&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;{&lt;font color="#008000"&gt;// Initialize the first update asynchronously&lt;br /&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font color="#2b91af"&gt;ElapsedEventHandler&lt;/font&gt; dlgt = eventTimer_Elapsed;&lt;/div&gt;
&lt;p&gt;dlgt.BeginInvoke(sender,e);&lt;/p&gt;
&lt;p&gt;}&lt;br /&gt;
&lt;font color="#0000ff"&gt;protected&lt;/font&gt; &lt;font color="#0000ff"&gt;override&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; OnContinue() &lt;br /&gt;
{&lt;br /&gt;
 &lt;font color="#0000ff"&gt;this&lt;/font&gt;.eventTimer.Start();&lt;br /&gt;
BeginInvokeElapsedEvent(&lt;font color="#0000ff"&gt;this&lt;/font&gt;,&lt;font color="#0000ff"&gt;null&lt;/font&gt;);&lt;font color="#008000"&gt;// MyLongProcess();&lt;br /&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;base&lt;/font&gt;.OnContinue ();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;protected&lt;/font&gt; &lt;font color="#0000ff"&gt;override&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; OnStart(&lt;font color="#0000ff"&gt;string&lt;/font&gt;[] args)&lt;br /&gt;
{&lt;/p&gt;
&lt;p&gt;Initialise();&lt;/p&gt;
&lt;p&gt;&lt;font color="#008000"&gt;// Initialize the first update asynchronously&lt;/font&gt;&lt;font color="#008000"&gt;// MyLongProcess();&lt;br /&gt;
&lt;/font&gt;BeginInvokeElapsedEvent(&lt;font color="#0000ff"&gt;this&lt;/font&gt;,&lt;font color="#0000ff"&gt;null&lt;/font&gt;);&lt;/p&gt;
&lt;div&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt; &lt;font color="#0000ff"&gt;void&lt;/font&gt; eventTimer_Elapsed(&lt;font color="#0000ff"&gt;object&lt;/font&gt; sender, &lt;font color="#2b91af"&gt;ElapsedEventArgs&lt;/font&gt; e)&lt;br /&gt;
{&lt;/p&gt;
&lt;p&gt;MyLongProcess();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;/div&gt;
Related links:&lt;a id="itoc" title="Comparing the Timer Classes in the .NET Framework Class Library" href="http://msdn.microsoft.com/en-au/magazine/cc164015.aspx#S4"&gt;Comparing the Timer Classes in the .NET Framework Class Library&lt;/a&gt;&lt;br /&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/132662.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/132662.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/132662.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/132662.aspx</trackback:ping>
    </entry>
    <entry>
        <title>LINQ to XML -How to use XPass for elements selection</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/mnf/archive/2009/05/20/linq-to-xml--how-to-use-xpass-for-selectio.aspx" />
        <id>http://geekswithblogs.net/mnf/archive/2009/05/20/linq-to-xml--how-to-use-xpass-for-selectio.aspx</id>
        <published>2009-05-20T21:58:52-05:00:00</published>
        <updated>2009-06-07T03:23:46Z</updated>
        <content type="html">&lt;div goog_docs_charindex="1"&gt;I am just starting to work with LINQ to XML and tried to find child document similar to the following:&lt;/div&gt;
&lt;div goog_docs_charindex="105"&gt; xml.Element("client/child");&lt;/div&gt;
&lt;div goog_docs_charindex="136"&gt;But it throw exception&lt;/div&gt;
&lt;div goog_docs_charindex="160"&gt;&lt;font color="#ff0000" goog_docs_charindex="161"&gt;System.Xml.XmlException: The '/' character, hexadecimal value 0x2F, cannot be included in a name.&lt;/font&gt;&lt;/div&gt;
&lt;div goog_docs_charindex="261"&gt;The reason is that LINQ to XML doesn't directly support XPAth&lt;/div&gt;
&lt;div goog_docs_charindex="324"&gt;Fortunately there &lt;a id="ixwv" title="are extensions, that allow" goog_docs_charindex="343" href="http://msmvps.com/blogs/luisabreu/archive/2008/05/07/linq-to-xml-using-xpath-expressions.aspx"&gt;are extensions, that allow&lt;/a&gt; to use XPath for XElement search/selection.&lt;/div&gt;
&lt;p goog_docs_charindex="417"&gt;&lt;font style="BACKGROUND-COLOR: #00ff00" goog_docs_charindex="418"&gt;using System.Xml.XPath;&lt;/font&gt;&lt;/p&gt;
&lt;p goog_docs_charindex="444"&gt;&lt;font style="BACKGROUND-COLOR: #ffffff" goog_docs_charindex="445"&gt;and then&lt;/font&gt;&lt;/p&gt;
&lt;p goog_docs_charindex="456"&gt;var clients = xml.&lt;a id="cd_8" title="XPathSelectElements" href="http://msdn.microsoft.com/en-us/library/system.xml.xpath.extensions.xpathselectelements.aspx"&gt;&lt;font style="BACKGROUND-COLOR: #00ff00"&gt;XPathSelectElements&lt;/font&gt;&lt;/a&gt; ( "client/child" );&lt;/p&gt;
&lt;p goog_docs_charindex="456"&gt;Consider, if required ,an &lt;a id="cd_8" title="XPathSelectElements" href="http://msdn.microsoft.com/en-us/library/bb356942.aspx"&gt;&lt;font color="#810081"&gt;XPathSelectElements&lt;/font&gt;&lt;/a&gt; overload  with namespace management.&lt;/p&gt;
&lt;p goog_docs_charindex="456"&gt;Note, that XPath extensions are actually backward compatibility feature, and&lt;font style="BACKGROUND-COLOR: #00ff00"&gt; Microsoft recommends to use native XElement methods&lt;/font&gt;, such as Descendants ,Elements,Element etc.  See &lt;a href="http://msdn.microsoft.com/en-us/library/bb675156.aspx"&gt;Comparison of XPath and LINQ to XML&lt;/a&gt;&lt;br /&gt;
 However &lt;a id="_ctl0__ctl0__ctl0__ctl0_BlogTitleHeader1__ctl0_BlogTitle" href="http://odetocode.com/Blogs/scott/default.aspx"&gt;K. Scott Allen&lt;/a&gt;  prefers to &lt;a href="http://odetocode.com/Blogs/scott/archive/2009/06/05/12881.aspx"&gt;mix LINQ and XPath  &lt;/a&gt;to have &lt;font face="Arial"&gt;concise &lt;/font&gt;code.&lt;/p&gt;
&lt;p class="subHeading" goog_docs_charindex="416"&gt;See also Concepts &lt;span&gt;&lt;a id="ctl00_mainContentContainer_ctl80" onclick="javascript:Track('ctl00_mainContentContainer_cpe510494_c|ctl00_mainContentContainer_ctl80',this);" href="http://msdn.microsoft.com/en-us/library/bb675178.aspx"&gt;LINQ to XML for XPath Users&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="subHeading" goog_docs_charindex="416"&gt;&lt;span&gt;Useful tip:&lt;a href="http://www.jetbrains.net/devnet/thread/279011"&gt;where clause and "Possible System.NullReferenceException"&lt;/a&gt; &lt;/span&gt;&lt;/p&gt;&lt;img src="http://geekswithblogs.net/mnf/aggbug/132304.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/mnf/comments/132304.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/mnf/comments/commentRss/132304.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/mnf/services/trackbacks/132304.aspx</trackback:ping>
    </entry>
</feed>