<rss version="2.0" 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:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Excentric shoot it later</title>
        <link>http://community.dotnetwork.it/Excentric/Default.aspx</link>
        <description>.Net Sql Server and neighbourhood</description>
        <language>en-US</language>
        <copyright>Sabrina C.</copyright>
        <managingEditor>ziayeye@ziayeye.it</managingEditor>
        <generator>Subtext Version 1.9.5.176</generator>
        <image>
            <title>Excentric shoot it later</title>
            <url>http://community.dotnetwork.it/images/RSS2Image.gif</url>
            <link>http://community.dotnetwork.it/Excentric/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>The maximum message size quota for incoming messages (65535) has been exceeded</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/10/14/the-maximum-message-size-quota-for-incoming-messages-65535-has.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/7e4b77af7742_1308C/exception_quota_2.png" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="exception_quota" border="0" alt="exception_quota" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/7e4b77af7742_1308C/exception_quota_thumb.png" width="456" height="271" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This exception is thrown by a WCF web service published on IIS if you try to download by soap a serialized object (an image for instance) which in  Base64 is longer than 2&lt;sup&gt;16&lt;/sup&gt;-1 bytes.&lt;/p&gt;  &lt;p&gt;To avoid the exception you need to change the Client Application configuration, not the server configuration. In my case it is a windows forms application built to test the service so I have to change the app.config, while in a web application I would have to change the web.config.&lt;/p&gt;  &lt;pre class="HtmlFormat"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;="utf-8"&lt;/span&gt; ?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;startup&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;supportedRuntime&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="v4.0"&lt;/span&gt; &lt;span class="attr"&gt;sku&lt;/span&gt;&lt;span class="kwrd"&gt;=".NETFramework,Version=v4.0,Profile=Client"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;startup&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;system.serviceModel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;bindings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;basicHttpBinding&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;binding&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="BasicHttpBinding_ISoapWS"&lt;/span&gt; &lt;span class="attr"&gt;closeTimeout&lt;/span&gt;&lt;span class="kwrd"&gt;="00:01:00"&lt;/span&gt;
          &lt;span class="attr"&gt;openTimeout&lt;/span&gt;&lt;span class="kwrd"&gt;="00:01:00"&lt;/span&gt; &lt;span class="attr"&gt;receiveTimeout&lt;/span&gt;&lt;span class="kwrd"&gt;="00:10:00"&lt;/span&gt; &lt;span class="attr"&gt;sendTimeout&lt;/span&gt;&lt;span class="kwrd"&gt;="00:01:00"&lt;/span&gt;
          &lt;span class="attr"&gt;allowCookies&lt;/span&gt;&lt;span class="kwrd"&gt;="false"&lt;/span&gt; &lt;span class="attr"&gt;bypassProxyOnLocal&lt;/span&gt;&lt;span class="kwrd"&gt;="false"&lt;/span&gt; &lt;span class="attr"&gt;hostNameComparisonMode&lt;/span&gt;&lt;span class="kwrd"&gt;="StrongWildcard"&lt;/span&gt;
          &lt;span class="attr"&gt;maxBufferSize&lt;/span&gt;&lt;span class="kwrd"&gt;="65535"&lt;/span&gt; &lt;span class="attr"&gt;maxBufferPoolSize&lt;/span&gt;&lt;span class="kwrd"&gt;="500000"&lt;/span&gt; &lt;span class="attr"&gt;maxReceivedMessageSize&lt;/span&gt;&lt;span class="kwrd"&gt;="65535"&lt;/span&gt;
          &lt;span class="attr"&gt;messageEncoding&lt;/span&gt;&lt;span class="kwrd"&gt;="Text"&lt;/span&gt; &lt;span class="attr"&gt;textEncoding&lt;/span&gt;&lt;span class="kwrd"&gt;="utf-8"&lt;/span&gt; &lt;span class="attr"&gt;transferMode&lt;/span&gt;&lt;span class="kwrd"&gt;="Buffered"&lt;/span&gt;
          &lt;span class="attr"&gt;useDefaultWebProxy&lt;/span&gt;&lt;span class="kwrd"&gt;="true"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;readerQuotas&lt;/span&gt; &lt;span class="attr"&gt;maxDepth&lt;/span&gt;&lt;span class="kwrd"&gt;="64"&lt;/span&gt; &lt;span class="attr"&gt;maxStringContentLength&lt;/span&gt;&lt;span class="kwrd"&gt;="65535"&lt;/span&gt; &lt;span class="attr"&gt;maxArrayLength&lt;/span&gt;&lt;span class="kwrd"&gt;="65535"&lt;/span&gt;
            &lt;span class="attr"&gt;maxBytesPerRead&lt;/span&gt;&lt;span class="kwrd"&gt;="4096"&lt;/span&gt; &lt;span class="attr"&gt;maxNameTableCharCount&lt;/span&gt;&lt;span class="kwrd"&gt;="16384"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;security&lt;/span&gt; &lt;span class="attr"&gt;mode&lt;/span&gt;&lt;span class="kwrd"&gt;="None"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;transport&lt;/span&gt; &lt;span class="attr"&gt;clientCredentialType&lt;/span&gt;&lt;span class="kwrd"&gt;="None"&lt;/span&gt; &lt;span class="attr"&gt;proxyCredentialType&lt;/span&gt;&lt;span class="kwrd"&gt;="None"&lt;/span&gt;
              &lt;span class="attr"&gt;realm&lt;/span&gt;&lt;span class="kwrd"&gt;=""&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;message&lt;/span&gt; &lt;span class="attr"&gt;clientCredentialType&lt;/span&gt;&lt;span class="kwrd"&gt;="UserName"&lt;/span&gt; &lt;span class="attr"&gt;algorithmSuite&lt;/span&gt;&lt;span class="kwrd"&gt;="Default"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;security&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;binding&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

      &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;basicHttpBinding&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;bindings&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;client&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;endpoint&lt;/span&gt; &lt;span class="attr"&gt;address&lt;/span&gt;&lt;span class="kwrd"&gt;="http://localhost/MyWebservice/ServiceClass.svc"&lt;/span&gt;
        &lt;span class="attr"&gt;binding&lt;/span&gt;&lt;span class="kwrd"&gt;="basicHttpBinding"&lt;/span&gt; &lt;span class="attr"&gt;bindingConfiguration&lt;/span&gt;&lt;span class="kwrd"&gt;="BasicHttpBinding_ISoapWS"&lt;/span&gt;
        &lt;span class="attr"&gt;contract&lt;/span&gt;&lt;span class="kwrd"&gt;="SoapWsTest.ISoapWS"&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="BasicHttpBinding_ISoapWS"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;client&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;system.serviceModel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;configuration&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;span class="attr"&gt;&lt;font color="#333333"&gt;On the above configuration you need to change the following attributes&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;span class="attr"&gt;maxBufferSize&lt;/span&gt;&lt;span class="kwrd"&gt;="65535"&lt;/span&gt; &lt;/li&gt;

  &lt;li&gt;&lt;span class="attr"&gt;maxBufferPoolSize&lt;/span&gt;&lt;span class="kwrd"&gt;="500000"&lt;/span&gt; &lt;/li&gt;

  &lt;li&gt;&lt;span class="attr"&gt;maxReceivedMessageSize&lt;/span&gt;&lt;span class="kwrd"&gt;="65535"&lt;/span&gt; &lt;/li&gt;

  &lt;li&gt;&lt;span class="attr"&gt;maxStringContentLength&lt;/span&gt;&lt;span class="kwrd"&gt;="65535"&lt;/span&gt; &lt;/li&gt;

  &lt;li&gt;&lt;span class="attr"&gt;maxArrayLength&lt;/span&gt;&lt;span class="kwrd"&gt;="65535"&lt;/span&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To a value you think is large enough for your needs. Pay attention if you don’t change them all, you will receive a further exception for each parameter not large enough. The value depends on you so if you need to read images or PDF files you can raise the values above the millions, because Base64 is one of the less optimized data exchange formats.&lt;/p&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/902.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/10/14/the-maximum-message-size-quota-for-incoming-messages-65535-has.aspx</guid>
            <pubDate>Fri, 14 Oct 2011 20:12:13 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/902.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/10/14/the-maximum-message-size-quota-for-incoming-messages-65535-has.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/902.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Wonderful Conversions</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/10/14/wonderful-conversions.aspx</link>
            <description>&lt;p&gt;Yesterday I’ve blogged a memo showing some unusual conversions due to a Checksum routine I wrote for &lt;a href="http://community.dotnetwork.it/alberto/default.aspx" target="_blank"&gt;Alberto&lt;/a&gt;. Today I discovered that the real checksum was a little more cumbersome than I thought so I publish a few more conversions I made, just to help who will have the “luck” to bang on this kind of things.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0080c0" size="3"&gt;&lt;strong&gt;Get a sub-array of a byte array&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] sourceArray;
... &lt;span class="rem"&gt;//Initialization with a file read or a serial port read&lt;/span&gt;
&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] destArray = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[desiredSublength]
Array.Copy(sourceArray, StartIndex, destArray, DestStartIndex, Length);&lt;/pre&gt;

&lt;p&gt;&lt;font color="#0080c0" size="3"&gt;&lt;strong&gt;Conversion of the bytes in correspondant ascii chars&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;char&lt;/span&gt;[] chars = System.Text.Encoding.UTF8.GetChars(destArray);&lt;/pre&gt;

&lt;p&gt;&lt;font color="#0080c0" size="3"&gt;&lt;strong&gt;Get a string from a portion of the characters array&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; subValue = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(charsArray, startIndex, length);&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#0080c0" size="3"&gt;Convert a string representing an hex number into a byte&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;byte&lt;/span&gt; myHexByte = Convert.ToByte(&lt;span class="str"&gt;"1C"&lt;/span&gt;, 16);&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#0080c0" size="3"&gt;Convert a byte into an HexNumber String&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; hexString = Convert.ToString(myByteValue, 16);&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#0080c0" size="3"&gt;Be sure the string has the correct Case&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; lowerHex = hexString.ToLower();
&lt;span class="kwrd"&gt;string&lt;/span&gt; upperHex = hexString.ToUpper();&lt;/pre&gt;

&lt;p&gt;That’s because db and DB are the same as a numeric value, but become different if you &lt;strong&gt;&lt;font color="#0080c0" size="3"&gt;convert the string to a char array&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;char&lt;/span&gt;[] hexLetters = upperHex.ToCharArray();&lt;/pre&gt;

&lt;p&gt;And then you &lt;strong&gt;&lt;font color="#0080c0" size="3"&gt;convert the char array back to a byte array&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] bytesFromHexLetters = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[hexLetters.Length];
&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; hexLetters.Length; i++)
{
   bytesFromHexLetters [i] = Convert.ToByte(chars[i]);
}&lt;/pre&gt;

&lt;p&gt;Try it with upper and lower case hex letters and you’ll see. And all this in a single checksum check routine &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smilewithtongueout" alt="Con la lingua fuori" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/I-Forget-the-opposite-convert-a-string-t_123E5/wlEmoticon-smilewithtongueout_2.png" /&gt; here we call this kind of things Simple Business Complication Office (sometimes it is a very crowded office).&lt;/p&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/899.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/10/14/wonderful-conversions.aspx</guid>
            <pubDate>Fri, 14 Oct 2011 19:23:43 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/899.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/10/14/wonderful-conversions.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/899.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Convert a byte[] in an int16[] and convert a number in a binary string</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/10/12/convert-a-byte-in-an-int16-and-convert-a-number.aspx</link>
            <description>&lt;p&gt;Two things you surely don’t do every day, especially if like me you work with database and user interfaces, but today Alberto asked me a little help with a byte array and a strange checksum and to be able to make the verifications manually I had to use both things in this subject. So I blog a note to know where to find them next time.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#0077b0" size="3"&gt;Convert a byte[] in a short[] (o int16[]) but it would be the same with int32 or int64:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;short&lt;/span&gt;[] GetShortArray(&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] pBaits)
{
    &lt;span class="kwrd"&gt;int&lt;/span&gt; length = pBaits.Length / 2 + pBaits.Length % 2;
    &lt;span class="kwrd"&gt;short&lt;/span&gt;[] ret = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;short&lt;/span&gt;[length];
    &lt;span class="kwrd"&gt;int&lt;/span&gt; j = 0;
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; pBaits.Length; i += 2)
    {
        ret[j] = BitConverter.ToInt16(pBaits, i);
        j++;
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
}&lt;/pre&gt;

&lt;p&gt;Obviously for the  int32 you have to move 4 bytes, for int64 8 byte and so on.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;short&lt;/span&gt;[] pippo = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;short&lt;/span&gt;[] { 100, 156, 234, 322 };
&lt;span class="kwrd"&gt;byte&lt;/span&gt;[] pluto = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt;[pippo.Length * 2];
&lt;span class="kwrd"&gt;int&lt;/span&gt; j = 0;
&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; pippo.Length; i++)
{
    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] pezzo = BitConverter.GetBytes(pippo[i]);
    pluto[j] = pezzo[0];
    j++;
    pluto[j] = pezzo[1];
    j++;
}

&lt;span class="kwrd"&gt;short&lt;/span&gt;[] resultShort = GetShortArray(pluto);&lt;/pre&gt;

&lt;p&gt;the awful test code above gives the following result:&lt;/p&gt;

&lt;p align="center"&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Un-paio-di-operazioni-rare-e-quindi-diff_105C3/convertino_02_2.jpg" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="convertino_02" border="0" alt="convertino_02" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Un-paio-di-operazioni-rare-e-quindi-diff_105C3/convertino_02_thumb.jpg" width="162" height="203" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’m sure there are much elegant ways to extract bytes from a short array, and if the bytes composing the array arrive you from a serial port there is no need for my first fake conversion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#006a9d" size="3"&gt;Convert a number in a string in binary format:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you need to examine an integer or a byte to make an Or or a Xor, the better way is verify the bits composing it, of course, the Windows scientific calculator is a good helper, but if you have a whole array of numbers it is a little bit slow, fortunately in the .Net framework you have the necessary classes.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetBitString(&lt;span class="kwrd"&gt;byte&lt;/span&gt; pVal)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; (Convert.ToString(pVal, 2));
}

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; GetOctalString(&lt;span class="kwrd"&gt;byte&lt;/span&gt; pVal)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; (Convert.ToString(pVal, 8));
}&lt;/pre&gt;

&lt;p&gt;I made 2 methods just because the second parameter is the numeric base for the number so 2 is binary 8 is octal, 16 is hexadecimal and so on. The result of my test is the following:&lt;/p&gt;

&lt;p align="center"&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Un-paio-di-operazioni-rare-e-quindi-diff_105C3/convertino_01_4.jpg" rel="lightbox"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="convertino_01" border="0" alt="convertino_01" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Un-paio-di-operazioni-rare-e-quindi-diff_105C3/convertino_01_thumb_1.jpg" width="158" height="188" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you can now verify[ 2&lt;sup&gt;3&lt;/sup&gt;+2&lt;sup&gt;4&lt;/sup&gt;+2&lt;sup&gt;6&lt;/sup&gt; = 88] binary [0 + 3x8&lt;sup&gt;1&lt;/sup&gt; + 1x8&lt;sup&gt;2&lt;/sup&gt; = 88].&lt;/p&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/897.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/10/12/convert-a-byte-in-an-int16-and-convert-a-number.aspx</guid>
            <pubDate>Wed, 12 Oct 2011 17:43:53 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/897.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/10/12/convert-a-byte-in-an-int16-and-convert-a-number.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/897.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Work with a simple HTTP Listener and avoid problems with BOM</title>
            <category>Data and Business Logic Development</category>
            <category>Web Development</category>
            <category>Winforms Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/10/09/work-with-a-simple-http-listener-and-avoid-problems-with.aspx</link>
            <description>&lt;p&gt;We are implementing an internal service (internal means that it runs on an intranet) for one of our softwares that exchanges messages with my application clients when they run on the users machines. The data exchanged is sent as an XML class to an HTTP Listener. &lt;/p&gt;  &lt;p&gt;It looked all simple and easy except that, when the XML class arrived to the Listener, the XML De-Serializer went nuts telling us the class was not correctly formatted.&lt;/p&gt;  &lt;p&gt;After some checks to verify if we did something wrong (I always start from the principle that the probability I make a mess is higher than the one that compiler or libraries from third parties are wrong) and not finding nothing in the serialization and deserialization routines, sniffing the data arriving in the request, we discovered that the serialized data got 3 bytes preceding the &amp;lt;?xml which starts every xml data, in Hexadecimal EB BB BF, we didn’t understand what it was, and after a moment thinking to what could be wrong in our code to produce such problem, we made a search through the internet and learn something important (as always you never stop learning things…) Anyway, we discovered these three characters are a BOM (Byte order Mark) that is automatically added by the system serializing in UTF-8 encoding. Notepad, Notepad++ and other text editors/readers ignore it so you never notice it’s existence, but it is there. The problem in my service was that when deserializing from a string the three characters were not discarded so the Deserialize method gave an error telling that it found bad characters at the beginning of the class.&lt;/p&gt;  &lt;p&gt;Is there a way to avoid the problem with BOM? Yes, it is one of the parameters of the &lt;font color="#00df38"&gt;&lt;strong&gt;XmlWriterSettings&lt;/strong&gt;&lt;/font&gt; &lt;/p&gt;  &lt;pre class="CSharpFormat"&gt;XmlWriterSettings xstt = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlWriterSettings();

xstt.Encoding = Encoding.UTF8 : &lt;span class="kwrd"&gt;new&lt;/span&gt; UTF8Encoding(&lt;span class="kwrd"&gt;false&lt;/span&gt;);
&lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlWriter writer = XmlWriter.Create(stream, xstt))
{
   ...
}&lt;/pre&gt;

&lt;p&gt;Using this option to serialize the class avoids the BOM and the deserialization problems. &lt;/p&gt;

&lt;p&gt;Hoping to help someone else solving this problem faster &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Occhiolino" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/d833b34e42a0_BE20/wlEmoticon-winkingsmile_2.png" /&gt;&lt;/p&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/894.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/10/09/work-with-a-simple-http-listener-and-avoid-problems-with.aspx</guid>
            <pubDate>Sun, 09 Oct 2011 19:49:47 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/894.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/10/09/work-with-a-simple-http-listener-and-avoid-problems-with.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/894.aspx</wfw:commentRss>
        </item>
        <item>
            <title>The Phantom Password &amp;hellip;</title>
            <category>Winforms Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/10/05/the-phantom-password-hellip.aspx</link>
            <description>&lt;p&gt;Between yesterday afternoon and today’s noon, two of us lost 4 x 2 = 8 hours of worktime to find the cause of the problem in this post’s subject. A class used many times in our projects suddenly stopped working it’s usual way giving strange error messages.&lt;/p&gt;  &lt;p&gt;I’m testing some classes for a new application using a Test application, the classes are using a SQLServer database, since I need to test on multiple databases, I’ve put on a form a textbox with the connectionstring to be able to change it on the fly.&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;strong&gt;Data Source&lt;/strong&gt;&lt;/font&gt;=NomeServer;&lt;strong&gt;&lt;font color="#0000ff"&gt;Initial Catalog&lt;/font&gt;&lt;/strong&gt;=NomeDatabase;&lt;font color="#0000ff"&gt;&lt;strong&gt;Password&lt;/strong&gt;&lt;/font&gt;=LaPassword;&lt;strong&gt;&lt;font color="#0000ff"&gt;User ID&lt;/font&gt;&lt;/strong&gt;=LUtente;&lt;/p&gt;  &lt;p&gt;The connection string was set as the one above, of all  the tests I made, just one uses a &lt;strong&gt;DataProvider&lt;/strong&gt; class, which contains a &lt;strong&gt;Dataset&lt;/strong&gt;, with one &lt;strong&gt;DataTable&lt;/strong&gt;, served by a &lt;strong&gt;SqlDataAdapter&lt;/strong&gt;, 4 &lt;strong&gt;SqlCommand&lt;/strong&gt; and a &lt;strong&gt;SqlConnection&lt;/strong&gt;. This is the kind of classes we use for CRUD on all our tables and they work fine. Yesterday, an operation made of: &lt;strong&gt;Fill&lt;/strong&gt; (call &lt;em&gt;DataAdapter’s Fill&lt;/em&gt;), &lt;strong&gt;AddRow&lt;/strong&gt;, &lt;strong&gt;Update&lt;/strong&gt; (call to &lt;em&gt;DataAdapter’supdate&lt;/em&gt;) gave an error telling that the user had no Login Rights on SQL Server.&lt;/p&gt;  &lt;p&gt;After 3 hours debugging step by step,  we discovered that the &lt;strong&gt;DataAdapter&lt;/strong&gt;, after calling the &lt;strong&gt;Fill&lt;/strong&gt; cutted the password from the ConnectionString property of the &lt;strong&gt;SqlConnection&lt;/strong&gt; class automatically. Being a class used on daily bases on all our applications we started wondering how was it possible that all worked correctly until yesterday.     &lt;br /&gt;After another hour of tests on various things, we debugged step by step one of our applications and we found out that we were not totally nuts, the difference was that the connection strings (built by a standard helper in all our applications) were made like the following one:&lt;/p&gt;  &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;strong&gt;Data Source&lt;/strong&gt;&lt;/font&gt;=NomeServer;&lt;font color="#0000ff"&gt;&lt;strong&gt;Initial Catalog&lt;/strong&gt;&lt;/font&gt;=NomeDatabase;&lt;font color="#0000ff"&gt;&lt;strong&gt;Password&lt;/strong&gt;&lt;/font&gt;=LaPassword;&lt;font color="#0000ff"&gt;&lt;strong&gt;User ID&lt;/strong&gt;&lt;/font&gt;=LUtente;&lt;strong&gt;&lt;font color="#0000ff"&gt;Persist Security Info&lt;/font&gt;&lt;/strong&gt;=true;&lt;/p&gt;  &lt;p&gt;So, if a  &lt;strong&gt;DataAdapter&lt;/strong&gt; after the first call to one of its commands, eats the password, this is why. If the Persist Security Info, which is by the way one of the Not recommended options, is not in the connectionstring, after the first Connection Open it is discarded automatically. On the documentation it is specified this is a logic thing made for security reasons. Anyway it is the kind of problem that makes you feel an idiot, asking yourself “How it is possible it never happened before?”&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:747ba95f-ee87-4126-baf0-38879fa8e063" class="wlWriterEditableSmartContent"&gt;Tag di Technorati: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SqlDataAdapter" rel="tag"&gt;SqlDataAdapter&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/892.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/10/05/the-phantom-password-hellip.aspx</guid>
            <pubDate>Wed, 05 Oct 2011 12:37:54 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/892.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/10/05/the-phantom-password-hellip.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/892.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to use IIS to debug a Service Application WCF on IIS 64Bit</title>
            <category>Web Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/09/27/how-to-use-iis-to-debug-a-service-application-wcf.aspx</link>
            <description>&lt;p&gt;This is as usual a post to avoid forgetting how to set up something you don’t do every day.&lt;/p&gt;  &lt;p&gt;When you create a new Webservice using a WCF service application project, the system proposes automatically to debug it on the development webserver. But if you need to test the service from different machines especially if you work in team with somebody who is developing the client, it could be difficult to set up a connection to the development webservice, so it is easier to publish the application on IIS. To do it you need to modify the application configuration:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_01_2.jpg" rel="lightbox"&gt;&lt;img style="display: inline" title="webapp_service_01" alt="webapp_service_01" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_01_thumb.jpg" width="618" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You need to select “Use local IIS Web Server”, confirm or change the project URL and click on Create Virtual Directory.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_05_2.jpg" rel="lightbox"&gt;&lt;img style="display: inline" title="webapp_service_05" alt="webapp_service_05" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_05_thumb.jpg" width="537" height="480" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Important!!! After the previous setting, change also the Output Path to the bin\ instead of bin\debug or bin\x86\debug or things won’t work correctly for the .dlls referenced.&lt;/p&gt;  &lt;p&gt;If you are working on a 64bit computer and your application is a 32 bit application, like in my case, you need to open the IIS manager.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_02_2.jpg" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="webapp_service_02" border="0" alt="webapp_service_02" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_02_thumb.jpg" width="644" height="118" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select the application pool used by the Webservice from the Application Pools list.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_03_2.jpg" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="webapp_service_03" border="0" alt="webapp_service_03" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_03_thumb.jpg" width="644" height="83" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click on the Application pool advanced settings.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_04_2.jpg" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="webapp_service_04" border="0" alt="webapp_service_04" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_04_thumb.jpg" width="397" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;activate the 32 bit applications and restart the Website.&lt;/p&gt;  &lt;p&gt;If launching the webservice application you obtain the following screenshot:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_06_2.jpg" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="webapp_service_06" border="0" alt="webapp_service_06" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_06_thumb.jpg" width="644" height="358" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Your webservice is working correctly you just need a startup page, but using the multiple startup projects from your    &lt;br /&gt;Solution &amp;gt; Right click &amp;gt; Properties&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_07_2.jpg" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="webapp_service_07" border="0" alt="webapp_service_07" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/Usare-IIS_EFBE/webapp_service_07_thumb.jpg" width="644" height="406" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can start both the webservice and a test application where you can add a webreference to your service and debug it.&lt;/p&gt;  &lt;p&gt;HTH&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:64eb351a-b941-41db-9465-02d0321eb621" class="wlWriterEditableSmartContent"&gt;Tag di Technorati: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ASP.Net" rel="tag"&gt;ASP.Net&lt;/a&gt;,&lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Webservices" rel="tag"&gt;Webservices&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/888.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/09/27/how-to-use-iis-to-debug-a-service-application-wcf.aspx</guid>
            <pubDate>Tue, 27 Sep 2011 16:00:31 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/888.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/09/27/how-to-use-iis-to-debug-a-service-application-wcf.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/888.aspx</wfw:commentRss>
        </item>
        <item>
            <title>HTTP Listener and XML</title>
            <category>Winforms Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/08/10/http-listener-and-xml.aspx</link>
            <description>&lt;p&gt;Today, working at a small project using the .Net object in the title, we found something weird; if I used an HTTP Get to send a string to the Listener and the string was a plain text like “Hello, I am the string”, it arrived exactly as it was sent, while if the string was the XML serialization of a custom object the result string was different when received and before the &amp;lt;?xml we found three characters, an i with an umlaot, a closing double quote, and an upside down question mark.   &lt;br /&gt;Digging into the string we found that the XML Serialization by default inserts as first character of a serialized string/file the unicode character  &lt;strong&gt;\UFEFF&lt;/strong&gt;, which is a non visible character (also notepad does not show it), this character is necessary to the device/software/whatever that receives the text to determine if it is &lt;em&gt;BigEndian&lt;/em&gt; or &lt;em&gt;LittleEndian&lt;/em&gt;, You can find the details here on &lt;a href="http://en.wikipedia.org/wiki/byte_order_mark"&gt;Wikipedia&lt;/a&gt; if you are curious. This unicode character can be omitted in serialization just asking it to the .NET serializer, changing a property in the &lt;font color="#7cc80b"&gt;&lt;strong&gt;XmlWriterSettings&lt;/strong&gt;&lt;/font&gt; that you give to the &lt;font color="#04a5e1"&gt;&lt;strong&gt;XmlSerializer&lt;/strong&gt;&lt;/font&gt; the property is &lt;font color="#ff0000"&gt;&lt;strong&gt;Encoding&lt;/strong&gt;&lt;/font&gt;=&lt;font color="#0000ff"&gt;&lt;strong&gt;false&lt;/strong&gt;&lt;/font&gt; to exclude the character. &lt;/p&gt;  &lt;p&gt;It is not exactly a solution, but it is a good workaround if you cannot do more. The real solution is call an &lt;strong&gt;UrlEncoding&lt;/strong&gt; of the XML string before sending it using the GET, or else, if you want to be sure everything remains unchanged, you can convert the XML string to BASE64 Using Encoding.Unicode to obtain a Byte Array from the string and then parse it when received from the listener. &lt;/p&gt;  &lt;p&gt;Usually the exception you receive when this problem happens is the following:&lt;/p&gt;  &lt;pre&gt;System.Xml.XmlException
Data at the root level is invalid. Line 1, position 1.&lt;/pre&gt;

&lt;p&gt;here is the screenshot of the XML string with the problem.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/HTTP-Listener-e-XML_C52C/xml_err_2.jpg" rel="lightbox"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="xml_err" border="0" alt="xml_err" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/HTTP-Listener-e-XML_C52C/xml_err_thumb.jpg" width="386" height="112" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:89c86d07-6a30-48cb-bdf3-a73c7ec5c474" class="wlWriterEditableSmartContent"&gt;Tag di Technorati: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/HTTPListener" rel="tag"&gt;HTTPListener&lt;/a&gt;,&lt;a href="http://technorati.com/tags/XML" rel="tag"&gt;XML&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Encoding" rel="tag"&gt;Encoding&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/861.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/08/10/http-listener-and-xml.aspx</guid>
            <pubDate>Wed, 10 Aug 2011 14:48:00 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/861.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/08/10/http-listener-and-xml.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/861.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Associate more domains to a website generated using Plesk</title>
            <category>Web Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/05/26/associate-more-domains-to-a-website-generated-using-plesk.aspx</link>
            <description>&lt;p&gt;It is probably well known from all those who use Plesk on a daily base, I instead use it rarely and I have a minimum knowledge of what functionalities it has. My company has rented a virtual server from a Hosting Provider, and as most of them do, they install Plesk by default on these servers probably to avoid millions of phone calls from unexpert users like me.&lt;/p&gt;  &lt;p&gt;It is normal for a company own more than one domain (.it, .com, .net, .eu) and more, each mapped on the company’s site and obviously we don’t make a copy of the site for each domain, or it will be depressing to keep them updated.&lt;/p&gt;  &lt;p&gt;In my case, the website has been created with DotNetNuke, which is so nice to allow not only the mapping of more domains on a single portal, but also, to make more portals on the same DNN.&lt;/p&gt;  &lt;p&gt;When you open Plesk Administration console, and you want to create the secondary domains the thing that comes to my mind first is click on New Domain, bu that option has only 3 possibilities, Fisical Domain, Forward, Frame Forward, and it is not what we need for the use with our DNN. &lt;/p&gt;  &lt;p&gt;What we have to do is click on the Domain that holds fisically the DNN and then use the Add Domain Alias option. This Creates an Alias on the Webserver, mapped on the same Website, it’s an operation very quick, just write the domain alias name and check the Web checkbox, then save.&lt;/p&gt;  &lt;p&gt;Done this, you have just to open the DNN using the Host user and map the new domains as portal aliases on any DNN Portal you like.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:36a5dae2-74cf-4259-9722-59c2e9a2c759" class="wlWriterSmartContent"&gt;Tag di Technorati: &lt;a href="http://technorati.com/tags/DNN" rel="tag"&gt;DNN&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Plesk" rel="tag"&gt;Plesk&lt;/a&gt;,&lt;a href="http://technorati.com/tags/domain" rel="tag"&gt;domain&lt;/a&gt;,&lt;a href="http://technorati.com/tags/alias" rel="tag"&gt;alias&lt;/a&gt;,&lt;a href="http://technorati.com/tags/portal" rel="tag"&gt;portal&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/826.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/05/26/associate-more-domains-to-a-website-generated-using-plesk.aspx</guid>
            <pubDate>Thu, 26 May 2011 11:20:34 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/826.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/05/26/associate-more-domains-to-a-website-generated-using-plesk.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/826.aspx</wfw:commentRss>
        </item>
        <item>
            <title>TFS Correct an error in Time</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/05/06/tfs-correct-an-error-in-time.aspx</link>
            <description>&lt;p&gt;It is something like Back to the Future applied to TFS 2010…&lt;/p&gt;  &lt;p&gt;Last May 5th in our office we had a Blackout, the servers shut down and we had a problem with the master domain controller restart, no one noticed that all developer computers and the TFS server had the clock moved ahead to May 8th until someone took a look at his calendar asking himself why was he at office on a sunday. &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="A bocca aperta" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/f19ff49d15e5_F2C2/wlEmoticon-openmouthedsmile_2.png" /&gt;&lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="A bocca aperta" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/f19ff49d15e5_F2C2/wlEmoticon-openmouthedsmile_2.png" /&gt;&lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="A bocca aperta" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/f19ff49d15e5_F2C2/wlEmoticon-openmouthedsmile_2.png" /&gt;.&lt;/p&gt;  &lt;p&gt;The clock was corrected immediately but some Checkins were done during the Time Warp. We did not give importance to this thing until this afternoon when on a checkin we had this nice error message.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font style="background-color: #ffff00"&gt;TF54000: Cannot update data because the server clock may have been set incorrectly. Contact your Team Foundation Server Administrator.&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Being the administrator it was easy to contact myself, &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smilewithtongueout" alt="Con la lingua fuori" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/f19ff49d15e5_F2C2/wlEmoticon-smilewithtongueout_2.png" /&gt; but of course I had no solution, fortunately with an easy Bing search I found the following 2 solutions posted on Microsoft Forums:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Wait to checkin after May 8th, could be done but it was not the best.&lt;/li&gt;    &lt;li&gt;Modify the Changesets with the wrong date on TFS database. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;We obviously choosed the second option, so I put the script we used to solve the problem:&lt;/p&gt;  &lt;pre&gt;UPDATE tbl_ChangeSet
	SET CreationDate = CreationDate -3 WHERE CreationDate &amp;gt; GETDATE()&lt;/pre&gt;

&lt;p&gt;This moved back to May 5th all the changesets with date and time in the future and then the checkins worked correctly.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:79b1cefc-adeb-422d-a2d2-2fe208b039a3" class="wlWriterEditableSmartContent"&gt;Tag di Technorati: &lt;a href="http://technorati.com/tags/TFS" rel="tag"&gt;TFS&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQLserver" rel="tag"&gt;SQLserver&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/805.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/05/06/tfs-correct-an-error-in-time.aspx</guid>
            <pubDate>Fri, 06 May 2011 15:42:39 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/805.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/05/06/tfs-correct-an-error-in-time.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/805.aspx</wfw:commentRss>
        </item>
        <item>
            <title>The solution to a small conversion problem</title>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/03/29/the-solution-to-a-small-conversion-problem.aspx</link>
            <description>&lt;p&gt;It’s not something we do on a daily base so I write it here to be able to find it when I need it.&lt;/p&gt;  &lt;p&gt;A colleague asked me a question on how to convert a VB function in C#, this function calculates the checksum for a string that has then to be sent through a serial port.&lt;/p&gt;  &lt;p&gt;The problem was that  VB converts a string “&amp;amp;HF6” to a short while my short.TryParse( “0xF6”, out val) don’t.&lt;/p&gt;  &lt;p&gt;The problem is determined by the fact that as a default TryParse expects to receive a number and an Hexadecimal virtually isnt.&lt;/p&gt;  &lt;p&gt;The solution is use the following:&lt;/p&gt;  &lt;pre&gt;val = Int16.Parse("0xF6", System.Globalization.NumberStyles.HexNumber);&lt;/pre&gt;

&lt;p&gt;Very easy, but it needed about half an hour finding and trying it, so I hope to help someone else spare that time &lt;img style="border-bottom-style: none; border-right-style: none; border-top-style: none; border-left-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Occhiolino" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/4ade8e62d92b_D1FF/wlEmoticon-winkingsmile_2.png" /&gt;&lt;/p&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/771.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/03/29/the-solution-to-a-small-conversion-problem.aspx</guid>
            <pubDate>Tue, 29 Mar 2011 13:10:51 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/771.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/03/29/the-solution-to-a-small-conversion-problem.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/771.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Capture screenshots from multiple screens in C#</title>
            <category>Winforms Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/01/17/capture-screenshots-from-multiple-screens-in-c.aspx</link>
            <description>&lt;p&gt;Today Stefano, a friend asked a question on our forum that looked very easy to answer.&lt;/p&gt;
&lt;p&gt;“I Use Screen.PrimaryScreen to capture the screen in C# but I have a multiple screen environment (4 screens) and I need to capture them all. Any Ideas?”&lt;/p&gt;
&lt;p&gt;The Answer was simple, Screen class has an AllScreens Property which is an array giving us all the screens connected to the PC, using that you can easily Capture Each screen image using a for cycle with the following code for each screen:&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;                Bitmap ps = &lt;span class="kwrd"&gt;new&lt;/span&gt; Bitmap(x.Bounds.Width, x.Bounds.Height);

                Graphics graphics = Graphics.FromImage(ps &lt;span class="kwrd"&gt;as&lt;/span&gt; Image);
                graphics.CopyFromScreen(x.Bounds.X, x.Bounds.Y, 0, 0, x.Bounds.Size);

                ps.Save(&lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;@"c:\MultiImage{0}.jpg"&lt;/span&gt;, i), ImageFormat.Jpeg);

                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"DONE &amp;lt;{0}&amp;gt; "&lt;/span&gt;, i) + Environment.NewLine;&lt;/pre&gt;
&lt;p&gt;But what He really wanted was a single image containing the whole screen, the same thing you obtain using a printscreen. &lt;br /&gt;
And that’s not so simple.&lt;/p&gt;
&lt;p&gt;Infact, I made a test with 2 screens, using my notebook, and Windows Vista and 7 (I don’t remember if XP made the same), when you have multiple screens allows you to position the secondary screens on whatever side of your primary screen you desire, changing consequently the properties indicating where the secondary screen (or screens) are positioned based on the primary one.&lt;/p&gt;
&lt;p&gt;Because of this, composing an image is not so easy and requires some calculations, (of course you can use the clipboard if you prefer, but we are here to learn C# and use .NET right?).&lt;/p&gt;
&lt;p&gt;This is what I ended up with:&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; width = 0;
            &lt;span class="kwrd"&gt;int&lt;/span&gt; height = 0;
            &lt;span class="kwrd"&gt;int&lt;/span&gt; minx = 0;
            &lt;span class="kwrd"&gt;int&lt;/span&gt; miny = 0;
            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; Screen.AllScreens.Length; i++)
            {
                Screen z = Screen.AllScreens[i];
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (z.Bounds.X &amp;lt; minx) minx = z.Bounds.X;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (z.Bounds.Y &amp;lt; miny) miny = z.Bounds.Y;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (i == 0)
                {
                    width = z.Bounds.Width;
                    height = z.Bounds.Height;
                }
                &lt;span class="kwrd"&gt;else&lt;/span&gt;
                {
                    Screen p = Screen.AllScreens[i - 1];
                    &lt;span class="rem"&gt;//Sta a destra&lt;/span&gt;
                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (z.Bounds.Right &amp;gt; p.Bounds.Right)
                    {
                        width += z.Bounds.Right - p.Bounds.Right;
                    }
                    &lt;span class="kwrd"&gt;else&lt;/span&gt;
                    {
                        &lt;span class="rem"&gt;//sta a sinistra&lt;/span&gt;
                        &lt;span class="kwrd"&gt;if&lt;/span&gt; (z.Bounds.Left &amp;lt; p.Bounds.Left)
                        {
                            width += Math.Abs(p.Bounds.Left - z.Bounds.Left);
                        }
                    }
                    &lt;span class="rem"&gt;//sta sopra&lt;/span&gt;
                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (z.Bounds.Top &amp;lt; p.Bounds.Top)
                    {
                        height += (Math.Abs(z.Bounds.Top) - Math.Abs(z.Bounds.Bottom));
                    }
                    &lt;span class="kwrd"&gt;else&lt;/span&gt;
                    {
                        &lt;span class="kwrd"&gt;if&lt;/span&gt; (z.Bounds.Bottom &amp;gt; p.Bounds.Bottom)
                        {
                            height += z.Bounds.Bottom - p.Bounds.Bottom;
                        }
                    }

                }
            }&lt;/pre&gt;
&lt;p&gt;Based on the secondary screen position I’ve calculated the total image width and height and the offset of the bitmaps.&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;            Bitmap ps = &lt;span class="kwrd"&gt;new&lt;/span&gt; Bitmap(width, height);
            Graphics graphics = Graphics.FromImage(ps &lt;span class="kwrd"&gt;as&lt;/span&gt; Image);

            &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text = &lt;span class="str"&gt;""&lt;/span&gt;;
            &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 0; i &amp;lt; Screen.AllScreens.Length; i++)
            {
                Screen x = Screen.AllScreens[i];
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"-------------------&amp;gt;{0}&amp;lt;-------------------------"&lt;/span&gt;, i)&lt;br /&gt;                    + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="str"&gt;"Top:"&lt;/span&gt; + x.Bounds.Top.ToString() + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="str"&gt;"Bottom:"&lt;/span&gt; + x.Bounds.Bottom.ToString() + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="str"&gt;"Left:"&lt;/span&gt; + x.Bounds.Left.ToString() + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="str"&gt;"Right:"&lt;/span&gt; + x.Bounds.Right.ToString() + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="str"&gt;"X:"&lt;/span&gt; + x.Bounds.X.ToString() + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="str"&gt;"Y:"&lt;/span&gt; + x.Bounds.Y.ToString() + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="str"&gt;"Width:"&lt;/span&gt; + x.Bounds.Width.ToString() + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="str"&gt;"Height:"&lt;/span&gt; + x.Bounds.Height.ToString() + Environment.NewLine;
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"-------------------&amp;lt;{0}&amp;gt;-------------------------"&lt;/span&gt;,&lt;br /&gt;                     i) + Environment.NewLine;
                graphics.CopyFromScreen(x.Bounds.X, x.Bounds.Y, x.Bounds.X + (Math.Abs(minx)),&lt;br /&gt;                      x.Bounds.Y + Math.Abs(miny), x.Bounds.Size);

                ps.Save(&lt;span class="str"&gt;@"c:\SingleImage.jpg"&lt;/span&gt;, ImageFormat.Jpeg);
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.textBox1.Text += &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"DONE &amp;lt;{0}&amp;gt; "&lt;/span&gt;, i) + Environment.NewLine;
            }&lt;/pre&gt;
&lt;p&gt;Then I compose the bitmap joining the two pieces of screen. I’m sure there is a better way of doing it, and of course &lt;br /&gt;
You probably need to change some things to make it work with three or more screens. &lt;br /&gt;
If you try it, let me know.&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:2ab1b8ee-a87d-4249-9e38-5be8ea8a5c93" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a rel="tag" href="http://technorati.com/tags/C%23"&gt;C#&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/capture+screen"&gt;capture screen&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;
&lt;/p&gt;&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" class="wlWriterEditableSmartContent"&gt;To download the code, Log in and go to &lt;a href="http://www.dotnetwork.it/Contenuti/Risorse/tabid/63/Default.aspx"&gt;resources area &lt;/a&gt;&lt;/div&gt;
&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/596.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/01/17/capture-screenshots-from-multiple-screens-in-c.aspx</guid>
            <pubDate>Mon, 17 Jan 2011 18:38:46 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/596.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/01/17/capture-screenshots-from-multiple-screens-in-c.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/596.aspx</wfw:commentRss>
        </item>
        <item>
            <title>E&amp;rsquo; arrivata la Befana&amp;hellip;</title>
            <category>Various</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2011/01/06/ersquo-arrivata-la-befanahellip.aspx</link>
            <description>&lt;p&gt;Sorry for the Italian title but there isn’t a translation for that.&lt;/p&gt;
&lt;p&gt;I had no time to read my personal mail account from last friday, this morning, opening outlook I found two messages from Alessandro Teglia of Microsoft and… I fell from the chair …  &lt;img src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/6dd36c05c3ee_FA70/wlEmoticon-openmouthedsmile_2.png" alt="Open-mouthed smile" class="wlEmoticon wlEmoticon-openmouthedsmile" style="border-style: none;" /&gt; it was the announcement of the MVP Award. So, aunt Yeye has arrived among MVPs. It is obviously something that makes you feel like walking ten inches from earth, it is not something happening every day, to receive an award recognizing your professional competence known all over the planet. So now all it comes to my mind is some sort of an Oscar speech, of course it would be ridiculous, so thanks to the MVP program people at Microsoft to acknowledge my 23 years of work with Microsoft technologies, a job that is still exciting and gripping as on my first day in front of an IBM XT trying the DOS commands to see how they work while reading the Operating System Manual.&lt;/p&gt;
&lt;p&gt;P.s. This:&lt;/p&gt;
&lt;p&gt; &lt;a rel="lightbox" href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/6dd36c05c3ee_FA70/befana_2.jpg"&gt;&lt;img height="215" width="244" border="0" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/Windows-Live-Writer/6dd36c05c3ee_FA70/befana_thumb.jpg" alt="befana" title="befana" style="border: 0px none ; background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" /&gt;&lt;/a&gt; is a Befana.&lt;/p&gt;
&lt;p&gt;She brings candies to the good kids in Italy on January 6th and brings Carbon to the bad kids. &lt;/p&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/594.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2011/01/06/ersquo-arrivata-la-befanahellip.aspx</guid>
            <pubDate>Thu, 06 Jan 2011 18:31:51 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/594.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2011/01/06/ersquo-arrivata-la-befanahellip.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/594.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Using Date differences to build a countdown to new year</title>
            <category>Winforms Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/12/30/using-date-differences-to-build-a-countdown-to-new-year.aspx</link>
            <description>&lt;p&gt;A small application inspired by Stefano Pranzo, to create a countdown to new year.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;a rel="lightbox" href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/UsareledifferenzefraDateperuncountdowndi_9F36/frmcountdown_2.jpg"&gt;&lt;img style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title="frmcountdown" border="0" alt="frmcountdown" width="546" height="356" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/UsareledifferenzefraDateperuncountdowndi_9F36/frmcountdown_thumb.jpg" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The final result is shown in the above image, to create it we have to create a new Windows Forms Application, rename its Form1 to FrmCountdown and change the following properties:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;BackgroundImage –&amp;gt;Choose an image from your disk using the 3 dots button and import it into the project resources. I’ve found the above one writing newyear on the bing image search. &lt;/li&gt;
    &lt;li&gt;BackgroundImageLayout –&amp;gt; Stretch &lt;/li&gt;
    &lt;li&gt;FormBorderStyle –&amp;gt; None &lt;/li&gt;
    &lt;li&gt;KeyPreview –&amp;gt; True (we will use it to manage quit application). &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We add a label to the form named lblCountdown with the following properties:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;BackColor –&amp;gt; transparent &lt;/li&gt;
    &lt;li&gt;Font Name –&amp;gt; Lucida Calligraphy &lt;/li&gt;
    &lt;li&gt;Font Size –&amp;gt; 64 &lt;/li&gt;
    &lt;li&gt;Forecolor –&amp;gt; Gold &lt;/li&gt;
    &lt;li&gt;TextAlign –&amp;gt; MiddleCenter &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We add a button to the form named btnClose with the following properties:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;UseVisualStyleBackColor –&amp;gt; False &lt;/li&gt;
    &lt;li&gt;FlatStyle –&amp;gt; Flat &lt;/li&gt;
    &lt;li&gt;BackColor –&amp;gt; transparent &lt;/li&gt;
    &lt;li&gt;Font Name –&amp;gt; Lucida Calligraphy &lt;/li&gt;
    &lt;li&gt;Forecolor –&amp;gt; Gold &lt;/li&gt;
    &lt;li&gt;Text –&amp;gt; Close &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We add to the form a timer named tmrCountdown.&lt;/p&gt;
&lt;p&gt;The code behind the form is the following:&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; FrmCountDown()
        {
            InitializeComponent();
            tmrCountdown.Interval = 1000;
            tmrCountdown.Enabled = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
        }&lt;/pre&gt;
&lt;p&gt;In the form constructor we set the timer to an interval of 1000 milliseconds.&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; FrmCountDown_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            tmrCountdown.Start();
        }&lt;/pre&gt;
&lt;p&gt;On the Load  event of the form we activate the timer.&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnClose_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            Application.Exit();
        }&lt;/pre&gt;
&lt;p&gt;On the click event of the Close button we implement the application exit.&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; FrmCountDown_KeyUp(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, KeyEventArgs e)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (e.KeyCode == Keys.Escape)
            {
                Application.Exit();
            }
        }&lt;/pre&gt;
&lt;p&gt;On the key Up event of the form we implement the application exit if  Esc key is pressed.&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;        DateTime mDtEnd = &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(2011, 01, 01, 0, 0, 0);&lt;/pre&gt;
&lt;p&gt;We set a DateTime variable at form level with the final date and time, so 00:00:00 of january first.&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; tmrCountdown_Tick(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            TimeSpan sp = mDtEnd.Subtract(DateTime.Now);
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.lblCountdown.Text = sp.TotalHours.ToString(&lt;span class="str"&gt;"###"&lt;/span&gt;) + &lt;span class="str"&gt;":"&lt;/span&gt; + &lt;br /&gt;                sp.Minutes.ToString(&lt;span class="str"&gt;"0#"&lt;/span&gt;) + &lt;span class="str"&gt;":"&lt;/span&gt; + sp.Seconds.ToString(&lt;span class="str"&gt;"0#"&lt;/span&gt;);
            Application.DoEvents();
        }&lt;/pre&gt;
&lt;p&gt;Finally on the Tick event of the timer we update  our label calculating a difference between present date and time and the final date and time, converting then the data in a formatted string. As you can see we use the Subtract method of the DateTime class and the properties TotalHours, Minutes and Seconds of the Timespan representing the difference between the two dates.&lt;/p&gt;
&lt;p&gt;Our NewYear Countdown is ready to go.&lt;br /&gt;
You can find the full project with working code in the resources area &lt;a href="http://www.dotnetwork.it/Contenuti/Risorse/tabid/63/Default.aspx"&gt;Cpde for Countdown&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Happy newyear Everybody!&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9894c469-aad4-4f83-a5ce-df940bde63f9" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a rel="tag" href="http://technorati.com/tags/DateTime"&gt;DateTime&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/Winforms"&gt;Winforms&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/588.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/12/30/using-date-differences-to-build-a-countdown-to-new-year.aspx</guid>
            <pubDate>Thu, 30 Dec 2010 10:49:41 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/588.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/12/30/using-date-differences-to-build-a-countdown-to-new-year.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/588.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Working with XML part 2</title>
            <category>Data and Business Logic Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/11/01/working-with-xml-part-2.aspx</link>
            <description>&lt;h3&gt;What the system offers for free&lt;/h3&gt;
&lt;p&gt;As I explained in previous post, .NET is very XML friendly, so it gives us a few base functionalities to avoid us doing things already done, here we say it saves us from inventing hot water. To demostrate the basic functionalities I build a simple, fundamentally useless class that demonstrates us how the basic data types of .NET are all serializable.&lt;/p&gt;
&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;
&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; DnwEnitities.Entities
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Serializzabile
    {

        &lt;span class="kwrd"&gt;public&lt;/span&gt; Serializzabile()
        {
            TheChar = &lt;span class="str"&gt;'A'&lt;/span&gt;;
            TheByte = 10;
            TheBool = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            TheShort = 100;
            TheInt = 1000;
            TheLong = 1000000;
            TheFloat = 1234.7899f;
            TheDouble = 9800000.89600;
            TheDecimal = 766000000.654390001m;
            TheString = &lt;span class="str"&gt;"The string is very nice and useful."&lt;/span&gt;;
            TheDate = DateTime.Now;
            TheGuid = Guid.NewGuid();
            TheEnum = SerializableEnum.ALot;
        }
    
        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;char&lt;/span&gt; TheChar
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;byte&lt;/span&gt; TheByte
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; TheBool
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;short&lt;/span&gt; TheShort
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; TheInt
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;long&lt;/span&gt; TheLong
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;float&lt;/span&gt; TheFloat
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;double&lt;/span&gt; TheDouble
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;decimal&lt;/span&gt; TheDecimal
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; TheString
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; DateTime TheDate
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; Guid TheGuid
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; SerializableEnum TheEnum
        {
            get;
            set;
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; Serializzabile ReadXml(&lt;span class="kwrd"&gt;string&lt;/span&gt; pSerializedData, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pIsXmlData)
        {
            Serializzabile retP = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!pIsXmlData)
            {
                retP = (Serializzabile)SerializeHelper.DeserializeFromFile(&lt;br /&gt;                   &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Serializzabile), pSerializedData);
            }
            &lt;span class="kwrd"&gt;else&lt;/span&gt;
            {
                retP = (Serializzabile)SerializeHelper.DeserializeFromString(&lt;br /&gt;                   &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Serializzabile), pSerializedData);
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (retP);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; WriteXml(&lt;span class="kwrd"&gt;string&lt;/span&gt; pFileName)
        {
            SerializeHelper.SerializeToFile(pFileName, &lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Serializzabile), &lt;span class="kwrd"&gt;false&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;virtual&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; WriteXml()
        {
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (SerializeHelper.SerializeToString(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;false&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty));
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ToString()
        {
            StringBuilder sb = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder();
            sb.AppendFormat(&lt;span class="str"&gt;"Char: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheChar);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Byte: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheByte);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Bool: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheBool);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Short: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheShort);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Int: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheInt);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Long: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheLong);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Float: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheFloat);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Double: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheDouble);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Decimal: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheDecimal);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"String: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheString);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Date: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheDate);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Guid: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheGuid);
            sb.AppendLine();
            sb.AppendFormat(&lt;span class="str"&gt;"Enum: {0}"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.TheEnum);
            sb.AppendLine();
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (sb.ToString());
        }

    }

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; SerializableEnum : &lt;span class="kwrd"&gt;int&lt;/span&gt;
    {
        None = 0,
        All,
        Some,
        ALot
    }
    
}&lt;/pre&gt;
&lt;p&gt;This class represents the most raw and simple entity, it contains some public properties, one for each of the base data in .NET, it contains the WriteXml and ReadXml methods, using our Helper to write and read in XML the content of the class and an override of the ToString method that helps us visualize the class contents. There is also a simple Enumeration, showing us that enumerable values are serialized automatically.&lt;/p&gt;
&lt;p&gt;Instantiating a class of Serializzabile type, and calling its WriteXml method to write its content to a file, the content of the file is the &lt;br /&gt;
following:&lt;/p&gt;
&lt;pre class="HtmlFormat"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;="utf-8"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Serializzabile&lt;/span&gt; &lt;span class="attr"&gt;xmlns:xsi&lt;/span&gt;&lt;span class="kwrd"&gt;=&lt;a href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;&lt;/span&gt; &lt;br /&gt;&lt;span class="attr"&gt;     xmlns:xsd&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.w3.org/2001/XMLSchema"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheChar&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;65&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheChar&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheByte&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;10&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheByte&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheBool&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;true&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheBool&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheShort&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;100&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheShort&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheInt&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;1000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheInt&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheLong&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;1000000&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheLong&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheFloat&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;1234.78992&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheFloat&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheDouble&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;9800000.896&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheDouble&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheDecimal&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;766000000.654390001&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheDecimal&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheString&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;The string is very nice and useful.&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheString&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheDate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;2010-11-01T09:26:13.331+01:00&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheDate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheGuid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;3da90b04-ec02-4308-a177-fc6723ab8aa9&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheGuid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TheEnum&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;ALot&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TheEnum&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Serializzabile&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Using the ReadXml  to re-read the class, we will obtain an equivalent object. If we haven’t any particular requirement to satisfy in our programs, this is the simplest way to build a serializable entity.&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f9cef952-a247-40e7-af19-b96c7a17cc4a" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/XML" rel="tag"&gt;XML&lt;/a&gt;,&lt;a href="http://technorati.com/tags/entities" rel="tag"&gt;entities&lt;/a&gt;,&lt;a href="http://technorati.com/tags/serialization" rel="tag"&gt;serialization&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/545.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/11/01/working-with-xml-part-2.aspx</guid>
            <pubDate>Mon, 01 Nov 2010 09:04:25 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/545.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/11/01/working-with-xml-part-2.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/545.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Moving a Team Foundation Server 2010 from a domain to another</title>
            <category>Various</category>
            <category>SQL Server DBA </category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/11/01/moving-a-team-foundation-server-2010-from-a-domain-to.aspx</link>
            <description>&lt;p&gt;This is the list of what we did a couple of weeks ago in my organization, moving our development TFS from a domain to another domain, I write it here in case someone else needs it and of course to find it out if I ever need this again.&lt;/p&gt;
&lt;p&gt;First thing to do is read carefully the TFS documentation on this matter, starting with the MSDN document titled &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/ms404883(printer).aspx"&gt;Move Team Foundation Server from One Environment to Another&lt;/a&gt; and reading carefully what to do in your specific case. Our move was the simplest one, We needed to move Our Single Server from domain XXX to domain YYY without changing anything.&lt;/p&gt;
&lt;p&gt;The first thing we did was a full backup of all the TFS databases from our SQL Server 2008. Then, we did a Ghost of the Server Hard Disk, to be sure to have the possibility to Rollback in case of problems.&lt;/p&gt;
&lt;p&gt;Then the procedure we followed was this:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;We created the same service users we had on our present environment on the new domain, this means, the TfsService user, the SQLService user, the Proxy User and other domain users required by the system and we give them the same passwords.&lt;/li&gt;
    &lt;li&gt;We opened the TFS configuration and write down on a notepad all user groups and all TFS groups and WIndows groups and users mapped to every TFS project inside our server paying attention to write down everything. This operation is important because the Group and User mapping on project will be cleared during the moving and to avoid developers from “Screaming” and “cursing you” because they’ve lost access to their projects you have to be careful on this.&lt;/li&gt;
    &lt;li&gt;Another important thing to remember is DO NOT CHANGE THE NAME OF THE SERVER IN THE NEW ENVIRONMENT this is Very Important, because SQL Server 2008 has some problems when you rename its instance under it’s nose. So if you change the servers naming in the new domain, for your sake, move your old servers with the same name and let them Die with that name.&lt;/li&gt;
    &lt;li&gt;After this, You have to kill the TFS services, you can do that using the TFSServiceControl command line utilities which is located under the Tools folder of the TFS 2010 installation folder. &lt;br /&gt;
    TfsServiceControl quiesce  &lt;br /&gt;
    is the command to shut down the services.&lt;/li&gt;
    &lt;li&gt;You also have to shut down IIS if you have sharepoint on the same machine and SQL Server services.&lt;/li&gt;
    &lt;li&gt;Now you have to move the server to the new domain, Remember to activate a local system Administrator User with a simple password, use a domain administrator with the rights to do so to remove the server from the old domain. Restart it, verify that the services are still stopped or stop them again using the local Administrator.&lt;/li&gt;
    &lt;li&gt;Remember also to activate the SA user with a password you know or to create a SQL Server user with SysAdmin rights giving it a password of your choice.&lt;/li&gt;
    &lt;li&gt;Join the server to the new domain. Change the Service users for SQL Server and TFS services to the one in the new domain and start SQL Server, do not yet start TFS.&lt;/li&gt;
    &lt;li&gt;Then you first need to open the SQL Server Management Studio and log on using SA or your personal Sysadmin, go to the Security folder and verify that local machine Windows Groups have mantained their rights. Then map the new domain Windows Groups or users you had on the old domain and assign them rights and roles on the TFS databases. Remove database mappings from the old users before deleting them.&lt;/li&gt;
    &lt;li&gt;You also need to go to the Users management of the local Server, and if you created local groups containing domain users or groups, you need to remap the users and groups from the new domain.&lt;/li&gt;
    &lt;li&gt;Then you need to use the Identities Command, which is one of the options provided by the TFSConfig command line utility of TFS to change inside the configuration database of TFS the SIDs of the Domain Users used to run TFS Services, the utility stays on the Tools folder of the TFS installation. There is an article on the msdn linked to the guide I linked at the beginning of this article that gives you all the informations on how to use it. The command is something like: &lt;br /&gt;
    TFSConfig Identities /change /fromdomain:olddomain /todomain:newdomain /account:accountname /toaccount:accountname &lt;br /&gt;
                               /sqlinstance:sqlserverinstancename /databasename:TfsConfigDatabase /account:sqlaccountname &lt;br /&gt;
    If you Kept instance names and user names and passwords identical on the two domains this is a simple routine operation and all works at first shot. So keep clearly in mind, no Server name change, no service user change, no password change.&lt;/li&gt;
    &lt;li&gt;In the unfortunate case you had to change a service user, there is another command of the TFSConfig utility, named Accounts, you can use to specify to TFS the new service accounts before executing the Identities command. &lt;/li&gt;
    &lt;li&gt;After this you can restart TFS using the TfsServiceControl unquiesce command.&lt;/li&gt;
    &lt;li&gt;Open the TFS configuration manager, go back to the User Access and permission configuration and restore for each project the Windows Users and groups and the TFS users and Groups that have been erased by the domain move. With a particular care for the Project collection valid users, Team Foundation Licensed Users whicy you find if your first installation was a Workgroup TFS is no more needed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After this procedures are completed, you can open a Visual Studio 2010 and attach to the TFS client from a computer in the new domain, if you did all well, the server will respond exactly as it responded on the old domain.&lt;/p&gt;
&lt;p&gt;I didn’t speak of Sharepoint, well we are a small team and don’t use sharepoint, but the migration guide gives you all the instruction to migrate also Sharepoint services, so I’m sure it works correctly.&lt;/p&gt;
&lt;div style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; DISPLAY: inline; FLOAT: none; PADDING-TOP: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:8b39fb62-ffa0-4c3e-baff-083af42a96a0" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a rel="tag" href="http://technorati.com/tags/TFS"&gt;TFS&lt;/a&gt;,&lt;a rel="tag" href="http://technorati.com/tags/SQL+Server+2008"&gt;SQL Server 2008&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/542.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/11/01/moving-a-team-foundation-server-2010-from-a-domain-to.aspx</guid>
            <pubDate>Mon, 01 Nov 2010 07:23:03 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/542.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/11/01/moving-a-team-foundation-server-2010-from-a-domain-to.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/542.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Working with XML part 1</title>
            <category>Data and Business Logic Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/10/31/working-with-xml-part-1.aspx</link>
            <description>&lt;p&gt;This is the first of a small series of posts dedicated to XML serialization, publishing the code I used for the last Workshop we did last month. I’ll start from the serialization Helper class, already discussed in the past, now revised for Framework 4.0.&lt;/p&gt;  &lt;p&gt;To persist on a disk a C# (orVB) class, you need to create it with some simple tricks to make it serializable. Serialization is a word I’ve started to listen around 2003 at the first conferences on .NET I attended to. Maybe it’s self explanatory for an English mother tongue, but it wasn’t for me. I needed a while to understand that Serialization is the way to persist on mass storage the state of an object to be able to rebuild the same object with the exactly same state as the one we persisted on disk.&lt;/p&gt;  &lt;p&gt;Entity classes are classes with no particular abilities, they are defined this way because they represent structured data, so entities are the classes representing a Data Model, it can be simple and persisted on a file, or complex, like a LinqToSql or EntityFramework model persisted on a database. Entities are the kind of class we will surely serialize someway.&lt;/p&gt;  &lt;p&gt;In .NET, you can serialize data in 2 ways, binary serialization and XML serialization. All the base data types in .NET are serializable, so any class containing only this kind of data, can be directly serialized with no particular modification except it needs to implement a parameterless constructor.&lt;/p&gt;  &lt;p&gt;What is automatically serialized by .NET in an object? The public properties. Why only these? I think it is because they represent the state of the object as it can be observed by who instantiated it, we can always modify the standard behaviour overriding the default serialization. In these articles we will however show only how to use the standard serialization and how to drive it how we desire just using a few simple functionalities given us by the framework itself.&lt;/p&gt;  &lt;h3&gt;SerializeHelper class&lt;/h3&gt;  &lt;p&gt;This class provides all serialization services for simple object and composite objects (collections or classes containing other classes). It uses the classes of the System.Xml and System.Xml.Serialization namespaces. Let’s see its methods.&lt;/p&gt;  &lt;h4&gt;BuildReader&lt;/h4&gt;  &lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; XmlTextReader BuildReader(&lt;span class="kwrd"&gt;string&lt;/span&gt; pXmlString)
        {
            NameTable nt = &lt;span class="kwrd"&gt;new&lt;/span&gt; NameTable();
            XmlNamespaceManager nsmgr = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlNamespaceManager(nt);
            nsmgr.AddNamespace(&lt;span class="str"&gt;"bk"&lt;/span&gt;, &lt;span class="str"&gt;"urn:sample"&lt;/span&gt;);

            XmlParserContext context = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlParserContext(&lt;span class="kwrd"&gt;null&lt;/span&gt;, nsmgr, &lt;span class="kwrd"&gt;null&lt;/span&gt;, XmlSpace.None);

            &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(pXmlString, XmlNodeType.Element, context));
        }&lt;/pre&gt;

&lt;p&gt;This first method, as it's name says, creates an XmlTextReader, that together with the correspondent XmlTextWriter are the base streams for reading and writing XML data. The method above has been designed to allow us to transform a string (such as a database field) in an Xml stream. The method generates a “fake” context to build the XmlTextReader to transform the string in a stream.&lt;/p&gt;

&lt;h4&gt;DeserializeFromString&lt;/h4&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; DeserializeFromString(Type pTypeToDeserialize, &lt;span class="kwrd"&gt;string&lt;/span&gt; pXmlString)
        {
            &lt;span class="kwrd"&gt;object&lt;/span&gt; ret = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlReader xr = BuildReader(pXmlString))
            {
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToDeserialize);
                ret = serializer.Deserialize(xr);
                xr.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; DeserializeFromString(Type pTypeToDeserialize, &lt;br /&gt;               Type[] pExtraTypes, &lt;span class="kwrd"&gt;string&lt;/span&gt; pXmlString)
        {
            &lt;span class="kwrd"&gt;object&lt;/span&gt; ret = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlReader xr = BuildReader(pXmlString))
            {
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToDeserialize, pExtraTypes);
                ret = serializer.Deserialize(xr);
                xr.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }&lt;/pre&gt;

&lt;p&gt;These two methods, one built for a class with only simple objects, another for a class with complex data types, use the previous method to create a stream that is then passed to the XmlSerializer class to get the object from the persisted string.&lt;/p&gt;

&lt;h4&gt;DeserializeFromFile&lt;/h4&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; DeserializeFromFile(Type pTypeToDeserialize, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPath)
        {
            &lt;span class="kwrd"&gt;object&lt;/span&gt; ret = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlTextReader reader = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(pPath))
            {
                &lt;span class="rem"&gt;// Occorre un'istanza della classe XmlSerializer&lt;/span&gt;
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToDeserialize);
                &lt;span class="rem"&gt;// e questo é tutto ciò che serve per leggere i dati dal formato XML&lt;/span&gt;
                ret = serializer.Deserialize(reader);
                reader.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; DeserializeFromFile(Type pTypeToDeserialize, &lt;br /&gt;            Type[] pExtraTypes, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPath)
        {
            &lt;span class="kwrd"&gt;object&lt;/span&gt; ret = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (XmlTextReader reader = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextReader(pPath))
            {
                &lt;span class="rem"&gt;// Occorre un'istanza della classe XmlSerializer&lt;/span&gt;
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToDeserialize, pExtraTypes);
                &lt;span class="rem"&gt;// e questo é tutto ciò che serve per leggere i dati dal formato XML&lt;/span&gt;
                ret = serializer.Deserialize(reader);
                reader.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }&lt;/pre&gt;

&lt;p&gt;The deserialization from a file is simpler, because XmlTextReader has a constructor that builds it from a file path. The two overloads of this method allow us to specify to the XmlSerializer the classes used if the objects involved are not simple classes. We will see it’s use when we will deserialize collections, but collections are not the only complex classes we will see.&lt;/p&gt;

&lt;h4&gt;SerializeToFile&lt;/h4&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SerializeToFile(&lt;span class="kwrd"&gt;string&lt;/span&gt; pPath, &lt;span class="kwrd"&gt;object&lt;/span&gt; pObjToSerialize, &lt;br /&gt;          Type pTypeToSerialize, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pNoNamespaces, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPrefix)
        {
            FileInfo fInfo = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(pPath);
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!Directory.Exists(fInfo.DirectoryName))
            {
                Directory.CreateDirectory(fInfo.DirectoryName);
            }            
            &lt;span class="kwrd"&gt;using&lt;/span&gt;(XmlTextWriter writer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextWriter(pPath, Encoding.UTF8))
            {
                &lt;span class="rem"&gt;// write a readable file&lt;/span&gt;
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;

                &lt;span class="rem"&gt;// Occorre un'istanza della classe XmlSerializer&lt;/span&gt;
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToSerialize);
                XmlSerializerNamespaces ns = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializerNamespaces();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; prefix = pPrefix != &lt;span class="kwrd"&gt;null&lt;/span&gt; ? pPrefix : &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pNoNamespaces)
                {
                    ns.Add(prefix, TXT_Namespace);
                }
                &lt;span class="rem"&gt;// e questo é tutto ciò che serve per persistere i dati&lt;/span&gt;
                serializer.Serialize(writer, pObjToSerialize, ns);
                writer.Close();
            }
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SerializeToFile(&lt;span class="kwrd"&gt;string&lt;/span&gt; pPath, &lt;span class="kwrd"&gt;object&lt;/span&gt; pObjToSerialize, 
            Type pTypeToSerialize, Type[] pExtraTypes, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pNoNamespaces, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPrefix)
        {
            FileInfo fInfo = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileInfo(pPath);
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!Directory.Exists(fInfo.DirectoryName))
            {
                Directory.CreateDirectory(fInfo.DirectoryName);
            }            
            &lt;span class="kwrd"&gt;using&lt;/span&gt;(XmlTextWriter writer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlTextWriter(pPath, Encoding.UTF8))
            {
                &lt;span class="rem"&gt;// write a readable file&lt;/span&gt;
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;
                &lt;span class="rem"&gt;//writer.Settings.OutputMethod = XmlOutputMethod.&lt;/span&gt;
                &lt;span class="rem"&gt;// Occorre un'istanza della classe XmlSerializer&lt;/span&gt;
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pTypeToSerialize, pExtraTypes);
                XmlSerializerNamespaces ns = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializerNamespaces();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; prefix = pPrefix != &lt;span class="kwrd"&gt;null&lt;/span&gt; ? pPrefix : &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pNoNamespaces)
                {
                    ns.Add(prefix, TXT_Namespace);
                }
                &lt;span class="rem"&gt;// e questo é tutto ciò che serve per persistere i dati&lt;/span&gt;
                serializer.Serialize(writer, pObjToSerialize, ns);
                writer.Close();
            }
        }&lt;/pre&gt;

&lt;p&gt;For the serialization, we made the two overloads with informations on the classes and we added a few parameters that allow us to format the classes, pNoNamespaces and pPrefix.&lt;/p&gt;

&lt;p&gt;In the code we can see how, creating the XmlTextWriter we can decide the Encoding used for the generated string, our method uses UTF8 standard serialization but if we need something else we can use another encoding. We can also control the Xml File formatting both using the Formatting Property and some other properties to determine indentation and indentation character.&lt;/p&gt;

&lt;p&gt;The use of XmlSerializerNamespaces allows us to avoid the verbose series of the namespaces inserted automatically in the first element of a serialized class:&lt;/p&gt;

&lt;p&gt;&amp;lt;Serializzabile xmlns:xsi="&lt;a href="http://www.w3.org/2001/XMLSchema-instance&amp;quot;"&gt;http://www.w3.org/2001/XMLSchema-instance"&lt;/a&gt; xmlns:xsd="&lt;a href="http://www.w3.org/2001/XMLSchema&amp;quot;"&gt;http://www.w3.org/2001/XMLSchema"&lt;/a&gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;Replacing this with:&lt;/p&gt;

&lt;p&gt;&amp;lt;Competences xmlns="&lt;a href="http://www.dotnetwork.it&amp;quot;"&gt;http://www.dotnetwork.it"&lt;/a&gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;Or, using the Nonamespace flag:&lt;/p&gt;

&lt;p&gt;&amp;lt;Competences&amp;gt;&lt;/p&gt;

&lt;p&gt;“killing” the namespaces is opportune to create neutral classes for data exchange between different companies and softwares, while if we want to be sure that our own classes are marked specifically to make them unique, we can add our namespace (usually it is the domain name of our website).&lt;/p&gt;

&lt;p&gt;the pPrefix parameter has instead the purpouse to allow us to set a prefix on the name of our classes to obtain the following effect:&lt;/p&gt;

&lt;p&gt;&amp;lt;dnw:Programmer xmlns:dnw="&lt;a href="http://www.dotnetwork.it"&gt;http://www.dotnetwork.it"&lt;/a&gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;dnw:Skills&amp;gt;&lt;/p&gt;

&lt;p&gt;It allows us to specify in detail the use of our own objects without a full namespace attribute on each of them.&lt;/p&gt;

&lt;h4&gt;SerializeToString&lt;/h4&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SerializeToString(&lt;span class="kwrd"&gt;object&lt;/span&gt; pObjToSerialize, &lt;br /&gt;            Type[] pExtraTypes, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pNoNamespaces, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPrefix)
        {
            &lt;span class="kwrd"&gt;string&lt;/span&gt; ret = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream())
            {
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pObjToSerialize.GetType(), pExtraTypes);
                XmlSerializerNamespaces ns = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializerNamespaces();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; prefix = pPrefix != &lt;span class="kwrd"&gt;null&lt;/span&gt; ? pPrefix : &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pNoNamespaces)
                {
                    ns.Add(prefix, TXT_Namespace);
                }
                serializer.Serialize(stream, pObjToSerialize, ns);
                ret = Encoding.UTF8.GetString(stream.ToArray());
                stream.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }

        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SerializeToString(&lt;span class="kwrd"&gt;object&lt;/span&gt; pObjToSerialize, &lt;span class="kwrd"&gt;bool&lt;/span&gt; pNoNamespaces, &lt;span class="kwrd"&gt;string&lt;/span&gt; pPrefix)
        {
            &lt;span class="kwrd"&gt;string&lt;/span&gt; ret = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
            &lt;span class="kwrd"&gt;using&lt;/span&gt; (MemoryStream stream = &lt;span class="kwrd"&gt;new&lt;/span&gt; MemoryStream())
            {
                XmlSerializer serializer = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializer(pObjToSerialize.GetType());
                XmlSerializerNamespaces ns = &lt;span class="kwrd"&gt;new&lt;/span&gt; XmlSerializerNamespaces();
                &lt;span class="kwrd"&gt;string&lt;/span&gt; prefix = pPrefix != &lt;span class="kwrd"&gt;null&lt;/span&gt; ? pPrefix : &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pNoNamespaces)
                {
                    ns.Add(prefix, TXT_Namespace);
                }
                serializer.Serialize(stream, pObjToSerialize, ns);
                ret = Encoding.UTF8.GetString(stream.ToArray());
                stream.Close();
            }
            &lt;span class="kwrd"&gt;return&lt;/span&gt; (ret);
        }&lt;/pre&gt;

&lt;p&gt;The last method, with two overloads, allows us the Xml serialization of an object on a string instead of serializing it on a file stream. To be able to do so we need however a stream, we use the MemoryStream to avoid a file on disk, the Xml generation remain identical to the one that builds a file on disk.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:34aabb1a-0e90-48b7-8fd8-a98914f96dc4" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Xml" rel="tag"&gt;Xml&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Serializzazione" rel="tag"&gt;Serializzazione&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Helper" rel="tag"&gt;Helper&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/540.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/10/31/working-with-xml-part-1.aspx</guid>
            <pubDate>Sun, 31 Oct 2010 22:46:43 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/540.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/10/31/working-with-xml-part-1.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/540.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Remote debugging from Visual Studio 2010 some tips on real world experience.</title>
            <category>SQL Server DBA </category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/10/17/remote-debugging-from-visual-studio-2010-some-tips-on-real.aspx</link>
            <description>&lt;p&gt;This is a shadow post, I write all here as always to be able to find it when I need it, but I’m just the writer, the real experiment was done by my colleague Luca, who loves writing code but hates writing documentation, blogs, articles and speech in public conferences… I still hope to convince him open a blog but my chances are poor.&lt;/p&gt;
&lt;p&gt;Anyway this is it:&lt;/p&gt;
&lt;p&gt;We had a strange behaviour on a machine for a new installed application, the machine was on a different domain from the development machines, and we wanted to remote debug it, here is what we did:&lt;/p&gt;
&lt;p&gt;On the remote machine you want to debug you start mswsmon, the remote debug utility.   &lt;br /&gt;
on tools&amp;gt;options you can choose between:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;No Authentication&lt;/li&gt;
    &lt;li&gt;Windows Authentication&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Choosing number one, you can debug, but we were not able to load debug symbols, so searching for the problem was not easy not having code to look for. Even copying the .pdb files on the installation folder was useless.&lt;/p&gt;
&lt;p&gt;Choosing number two, being the destination machine on a different domain we had to do the following:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Create a local user on development machine and remote machine with administrator privileges and same password. Even though on the remote machine we think you just need Remote debug permissions.&lt;/li&gt;
    &lt;li&gt;Disable the firewall on both machines (We are sure we needed just a couple of ports enabled, but had no time to search them, and being on the same network, in the same office it was easier to do).&lt;/li&gt;
    &lt;li&gt;Using mswsmon, on the remote machine, logged with the user that had the problem with the application, create a server named &lt;a href="mailto:UserName@MachineName"&gt;UserName@MachineName&lt;/a&gt; where UserName is the name of the local user created on point 1. Start the application to debug.&lt;/li&gt;
    &lt;li&gt;Log on the development machine with the local user and password, open Visual Studio 2010, open remote debug using     &lt;br /&gt;
    Debug&amp;gt;Attach to process, choose:
    &lt;ul&gt;
        &lt;li&gt;Transport = default (Windows Authentication)&lt;/li&gt;
        &lt;li&gt;Qualifier = &lt;a href="mailto:UserName@MachineName"&gt;UserName@MachineName&lt;/a&gt; (the one set on point 3)&lt;/li&gt;
        &lt;li&gt;Search for the process, double click and confirm.&lt;/li&gt;
        &lt;li&gt;You are now attached to the process running on the remote machine.&lt;/li&gt;
    &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li&gt;We experimented also that if you have the same version of the program on Remote and Development machine, if you don’t have the .pdb files on the remote machine, you can use Debug&amp;gt;Windows&amp;gt;Modules window to search for the module or dll you are attached to and using context menu (right click) you can load symbols (PDB) from a file on the development machine.&lt;/li&gt;
&lt;/ol&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/527.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/10/17/remote-debugging-from-visual-studio-2010-some-tips-on-real.aspx</guid>
            <pubDate>Sun, 17 Oct 2010 13:31:07 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/527.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/10/17/remote-debugging-from-visual-studio-2010-some-tips-on-real.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/527.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Database owner change</title>
            <category>SQL Server DBA </category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/10/17/database-owner-change.aspx</link>
            <description>&lt;p&gt;Yesterday I was in the middle of a very rare kind of operation in my company IT System, we are changing our Domain, moving all computers and servers from a domain to another.&lt;/p&gt;  &lt;p&gt;One of the servers we moved is the TFS development server on which there is a SQL Server 2008 holding all our code and projects. The move to the new domain gave no problems at all, but as recommended we did not change the computer name.&lt;/p&gt;  &lt;p&gt;After the move we had to add the domain users and groups of the new domain to SQL Server replacing the domain users and groups of the old domain and we had no troubles in doing this operation except for one thing.&lt;/p&gt;  &lt;p&gt;Accessing the Properties of a database I had an error because the Database Owner was invalid and the Properties window for that database did not open at all.&lt;/p&gt;  &lt;p&gt;The problem is due to the fact that databases are Owned by the User that creates them, and the TFS Databases were owned by the user used for the installation. I suggest to those who administer a TFS SQL server to change the Database Owner to SA for all databases.&lt;/p&gt;  &lt;p&gt;Anyway it is not a big trouble, to take ownership of databases, what you need is to log in as a Sysadmin (SA would be the better), onto SQL Server and run the following script changing the USE clause to each database with Ownership problems and run it.&lt;/p&gt;  &lt;pre&gt;use DatabaseName
exec sp_changedbowner 'sa'&lt;/pre&gt;

&lt;p&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/SQL"&gt;SQL&lt;/a&gt;,&lt;a href="http://technorati.com/tags/TSQL"&gt;TSQL&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Database"&gt;Database&lt;/a&gt;&lt;/p&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/526.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/10/17/database-owner-change.aspx</guid>
            <pubDate>Sun, 17 Oct 2010 13:03:52 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/526.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/10/17/database-owner-change.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/526.aspx</wfw:commentRss>
        </item>
        <item>
            <title>DNN: How to use a page just as a menu option</title>
            <category>Various</category>
            <category>Web Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/10/10/dnn-how-to-use-a-page-just-as-a-menu.aspx</link>
            <description>&lt;p&gt;Today I’ve lost about half an hour trying to remember how to create a page on DNN just to use it as a menu option. So I write here how to do it to remember it for the next time :P.&lt;/p&gt;  &lt;p&gt;If my previous definition was not clear let’s use a sample of what I needed to do to make it clear:&lt;/p&gt;  &lt;p&gt;My goal was to build a Top level Menu named Association which gives access to several sub menus, Who we Are, Our Board of directors, Associates, Messageboard and more.&lt;/p&gt;  &lt;pre class="TsqlFormat"&gt;Association +
            |
            +-&lt;span class="rem"&gt;-- Who we are +&lt;/span&gt;
            |               |
            |               + Mission
            |               |
            |               + Board &lt;span class="kwrd"&gt;of&lt;/span&gt; directors
            |               |
            |               + Members
            +-&lt;span class="rem"&gt;-- Messageboard&lt;/span&gt;
            |
            +--- Newsletters&lt;/pre&gt;

&lt;p&gt;In Dnn to made this structure in menus you need to build a page for each option even if the page is not a real page like Association and WhoWe Are in my structure above.&lt;/p&gt;

&lt;p&gt;To avoid that users, clicking on Association without waiting the menu to open and show them the sub items, find themselves on a blank page, what you need to do is the following:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Open Admin -&amp;gt;Pages options.&lt;/li&gt;

  &lt;li&gt;Click on Association in the list.&lt;/li&gt;

  &lt;li&gt;Click the Modify Icon.&lt;/li&gt;

  &lt;li&gt;Open the Advanced Options collapsed section.&lt;/li&gt;

  &lt;li&gt;Scroll down to the Link URL Section.&lt;/li&gt;
&lt;/ol&gt;

&lt;p align="center"&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/DNNHowtouseapagejustasamenuoption_D6A1/dnnurlpage_2.jpg" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="dnnurlpage" border="0" alt="dnnurlpage" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/DNNHowtouseapagejustasamenuoption_D6A1/dnnurlpage_thumb.jpg" width="524" height="239" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Set the URL to a page of your site (like the Board of Directors in my structure), or else build a fake URL (“#”) to keep user on current page. Save changes and you are done.&lt;/p&gt;

&lt;p&gt;To undo this, if you need it you have to open the pages section under Admin, because neither the administrator or host has direct access to the page.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:62d16c95-b0f7-46c5-be16-656b5a6351c6" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/DNN" rel="tag"&gt;DNN&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/519.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/10/10/dnn-how-to-use-a-page-just-as-a-menu.aspx</guid>
            <pubDate>Sun, 10 Oct 2010 13:15:59 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/519.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/10/10/dnn-how-to-use-a-page-just-as-a-menu.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/519.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Configure SQL Server Database Mail to send Job Notifications</title>
            <category>SQL Server DBA </category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/09/16/configure-sql-server-database-mail-to-send-job-notifications.aspx</link>
            <description>&lt;p&gt;Today I was modifying the configuration of database mail on one of my company’s SQL Servers, so I decided to configure the Database mail on another server where it wasn’t yet configured. Being something made once every five years or more, I decided to publish the steps to do it, this way I can repeat the operation on my customers servers to be sure someone is alerted if something on the SQL Server goes wrong.&lt;/p&gt;  &lt;p&gt;My server is a SQL 2008 server, but the configuration is identical for SQL 2005.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail01_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail01" border="0" alt="tfsmail01" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail01_thumb.jpg" width="272" height="148" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Open the Server Management folder on SQL Management Studio and select Database Mail.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail02_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail02" border="0" alt="tfsmail02" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail02_thumb.jpg" width="544" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If it is the first configuration, leave the option as selected, elsewhere select the proper option and click NEXT.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail03_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail03" border="0" alt="tfsmail03" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail03_thumb.jpg" width="537" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Give the profile a proper name and description, Database Mail can be configured for other tasks then the simple Job notification, and you can have more than a single profile for the different tasks.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail04_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail04" border="0" alt="tfsmail04" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail04_thumb.jpg" width="604" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click on the ADD button to create a mail account that has to be used to send the e-mails, pay attention, if you already have an account the Window above does not appear automatically, it appears first a window to select an existing account with a button that allows you to create a new one that opens this window.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail05_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail05" border="0" alt="tfsmail05" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail05_thumb.jpg" width="569" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Fill in the account data with a name and a description, set the e-mail addresses and the SMTP server name and then fill the authentication credentials if necessary or leave the anonymous authentication (for example if the company SMTP server is configured to allow so).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail06_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail06" border="0" alt="tfsmail06" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail06_thumb.jpg" width="547" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Then you need to set the security data for the profile, to be able to send e-mails from the SQL Server Agent, it’s better to create a public profile.&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail07_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail07" border="0" alt="tfsmail07" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail07_thumb.jpg" width="541" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After clicking the NEXT button, you’ll see two verification and execution confirm windows, the latter shown above.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail08_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail08" border="0" alt="tfsmail08" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail08_thumb.jpg" width="156" height="41" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now select the Operators Folder inside the SQL Server Agent Objects folder and create a new Operator.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail09_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail09" border="0" alt="tfsmail09" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail09_thumb.jpg" width="529" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We just need to set the operator name and the e-mail where to send notifications, unless you want to set also Net Send and Pager for the operator.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail10_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail10" border="0" alt="tfsmail10" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail10_thumb.jpg" width="537" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In Every backup, Maintenance or Script Execution Job set inside the Agent, you need to set up the Operator, Check the E-Mail notification action and set wether to notify Job Completion or Just Job Error or Job Success.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail11_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail11" border="0" alt="tfsmail11" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail11_thumb.jpg" width="533" height="484" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now we need to right click the SQL Server Agent icon and select the Alert System, activating the Database mail profile we generated. If you don’t do this operation, the Agent ignores E-Mail notifications and does nothing, it does not give any error or warning message.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tfsmail12" border="0" alt="tfsmail12" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/ConfigurareSQLServerDatabaseMailperlinvi_DE7D/tfsmail12_thumb.jpg" width="236" height="96" /&gt;&lt;/p&gt;  &lt;p&gt;After the configuration of the Alert System you must Restart SQL Server Agent to activate the E-mail notification system for Jobs and Alerts.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a7c637e8-5f9e-4dc2-b5ed-03cf4c14a465" class="wlWriterEditableSmartContent"&gt;Tags: &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/SQLServer+2008/default.aspx" rel="tag"&gt;SQLServer 2008&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Job/default.aspx" rel="tag"&gt;Job&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Alert/default.aspx" rel="tag"&gt;Alert&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Database+Mail/default.aspx" rel="tag"&gt;Database Mail&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/512.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/09/16/configure-sql-server-database-mail-to-send-job-notifications.aspx</guid>
            <pubDate>Thu, 16 Sep 2010 14:16:52 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/512.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/09/16/configure-sql-server-database-mail-to-send-job-notifications.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/512.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Just for fun, if you ever asked yourself why they call them Bugs&amp;hellip;</title>
            <category>Various</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/09/09/just-for-fun-if-you-ever-asked-yourself-why-they.aspx</link>
            <description>&lt;p&gt;Today we found this nice explanation on the wikipedia.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/SevisietemaichiestiPerchsichiamanoBug_E594/firstbug_2.jpg" rel="lightbox"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="firstbug" border="0" alt="firstbug" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/SevisietemaichiestiPerchsichiamanoBug_E594/firstbug_thumb.jpg" width="607" height="504" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;it was indeed a bug :D :D :D&lt;/p&gt;  &lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Software_bug"&gt;http://en.wikipedia.org/wiki/Software_bug&lt;/a&gt;  to read the full article on wikipedia.&lt;/p&gt;  &lt;p&gt;And if you don’t know what is a relay, this is a sample, that’s why in 1945 a computer was large as a room ;P;P;P&lt;/p&gt;  &lt;p align="center"&gt;&lt;img alt="Un Relay" src="http://upload.wikimedia.org/wikipedia/en/4/4b/LatchingRelay_tn.jpg" /&gt;&lt;/p&gt;  &lt;p align="center"&gt;And if you need a DeBugger…&lt;/p&gt;  &lt;p align="center"&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/SevisietemaichiestiPerchsichiamanoBug_E594/bug_2.gif" rel="lightbox"&gt;&lt;img style="display: inline" title="bug" alt="bug" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/SevisietemaichiestiPerchsichiamanoBug_E594/bug_thumb.gif" width="50" height="45" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p align="center"&gt;this is patented :D&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:15d19ec1-9229-4159-a655-9eb0a933bccc" class="wlWriterEditableSmartContent"&gt;Tags: &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/bug/default.aspx" rel="tag"&gt;bug&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/debug/default.aspx" rel="tag"&gt;debug&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/509.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/09/09/just-for-fun-if-you-ever-asked-yourself-why-they.aspx</guid>
            <pubDate>Thu, 09 Sep 2010 14:24:24 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/509.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/09/09/just-for-fun-if-you-ever-asked-yourself-why-they.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/509.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Collection and predicates search elements without cycling</title>
            <category>Data and Business Logic Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/08/13/collection-and-predicates-search-elements-without-cycling.aspx</link>
            <description>&lt;p&gt;Among the most useful things when you work with collections, are Search methods, allowing us to find an element inside the collection using the value of one or more of his properties as a search criteria.&lt;/p&gt;  &lt;p&gt;These methods can be implemented both as Indexer (a property) or a specific method. The second option is necessary because often there are more properties of the same data type used to search a collection and you can implement only one indexer with a certain signature.&lt;/p&gt;  &lt;p&gt;Let’s work through some samples to see how to use predicates:&lt;/p&gt;  &lt;p&gt;Our Entity class, named AnagraficaAzienda, exposes the following properties:&lt;/p&gt;  &lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; DescrizioneRicerca //SearchDescription
&lt;span class="kwrd"&gt;string&lt;/span&gt; RagioneSociale //Company name
&lt;span class="kwrd"&gt;string&lt;/span&gt; PartitaIva //Vat Code
&lt;span class="kwrd"&gt;string&lt;/span&gt; Indirizzo //Address
&lt;span class="kwrd"&gt;string&lt;/span&gt; CAP //Zip code
&lt;span class="kwrd"&gt;string&lt;/span&gt; Citta //City
&lt;span class="kwrd"&gt;string&lt;/span&gt; PV //State or province
&lt;span class="kwrd"&gt;int&lt;/span&gt; IDTipo //Type
&lt;span class="kwrd"&gt;int&lt;/span&gt; IDAnagrafica //Identity&lt;/pre&gt;

&lt;p&gt;To create an Indexer to search through the SearchDescription we can use the following code:&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;public AnagraficaAzienda &lt;span class="kwrd"&gt;this&lt;/span&gt;[&lt;span class="kwrd"&gt;string&lt;/span&gt; pDescrizioneRicerca]
{
    get
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt;( Find(item=&amp;gt;item.DescrizioneRicerca==pDescrizioneRicerca);
    }
}&lt;/pre&gt;

&lt;p&gt;to create a method to get all elements that match a regular expression we can use the following code:&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; List&amp;lt;AnagraficaAzienda&amp;gt; FindWithRegEx( &lt;span class="kwrd"&gt;string&lt;/span&gt; pRegEx )
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; (FindAll(items =&amp;gt; Regex.Match(items.RagioneSociale, pRegEx).Success));
}&lt;/pre&gt;

&lt;p&gt;to create a method that returns the data using the Vat Code (PartitaIva) we can use the following code:&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; AnagraficaAzienda FindXPartitaIva(&lt;span class="kwrd"&gt;string&lt;/span&gt; pPartitaIva)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt;( Find(item=&amp;gt;item.PartitaIva==pPartitaIva);
}&lt;/pre&gt;

&lt;p&gt;To create a multi dimensional indexer we can use the following code&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; AnagraficaAzienda &lt;span class="kwrd"&gt;this&lt;/span&gt;[&lt;span class="kwrd"&gt;int&lt;/span&gt; pIDZona, &lt;span class="kwrd"&gt;int&lt;/span&gt; pIDAnagrafica]
{
    get
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt;( Find(item=&amp;gt;item.IDZona==pIDZona &amp;amp;&amp;amp; item.IDAnagrafica==pIDAnagrafica);
    }
}&lt;/pre&gt;

&lt;p&gt;as you can see, a Predicate allows us to use any kind of binary expression to match the entity fields with the search criteria we want to use.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:677451c8-0e78-48f4-b0b6-79d9ea72d764" class="wlWriterEditableSmartContent"&gt;Tags: &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Collection/default.aspx" rel="tag"&gt;Collection&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Predicate/default.aspx" rel="tag"&gt;Predicate&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/Find/default.aspx" rel="tag"&gt;Find&lt;/a&gt;, &lt;a href="http://community.dotnetwork.it/Sabrina/Tags/FindAll/default.aspx" rel="tag"&gt;FindAll&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/490.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/08/13/collection-and-predicates-search-elements-without-cycling.aspx</guid>
            <pubDate>Fri, 13 Aug 2010 15:29:07 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/490.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/08/13/collection-and-predicates-search-elements-without-cycling.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/490.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to create a Guid.Empty in SQL</title>
            <category>SQL Server DBA </category>
            <category>Data and Business Logic Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/08/10/how-to-create-a-guid.empty-in-sql.aspx</link>
            <description>&lt;p&gt;Last friday my colleague Luca was “fighting” with a problem in managing null values and GUIDs. A Guid is a value type so it is not nullable. In my stored procedures when using parameters for filtering, I use the NULL value as the default value to ignore a filter parameter.&lt;/p&gt;  &lt;p&gt;Changing the code of several classes to be able to change a Guid.Empty into a DbNull before passing it to a SELECT command was decisely not the best thing to do, so we searched a way to recreate a Guid.Empty value in SQL.&lt;/p&gt;  &lt;p&gt;We were able to create the small snippet of SQL in the following function:&lt;/p&gt;  &lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;CREATE&lt;/span&gt; &lt;span class="kwrd"&gt;FUNCTION&lt;/span&gt; Guid_Empty()
&lt;span class="kwrd"&gt;RETURNS&lt;/span&gt; UniqueIdentifier
&lt;span class="kwrd"&gt;AS&lt;/span&gt;
&lt;span class="kwrd"&gt;BEGIN&lt;/span&gt;
&lt;span class="kwrd"&gt;RETURN&lt;/span&gt; &lt;span class="kwrd"&gt;cast&lt;/span&gt;(&lt;span class="kwrd"&gt;cast&lt;/span&gt;(0 &lt;span class="kwrd"&gt;as&lt;/span&gt; &lt;span class="kwrd"&gt;binary&lt;/span&gt;) &lt;span class="kwrd"&gt;as&lt;/span&gt; uniqueidentifier)
&lt;span class="kwrd"&gt;END&lt;/span&gt;
GO&lt;/pre&gt;

&lt;p&gt;After the creation of the above function and a simple table on my Paperinik Database,  I was able to write the following query:&lt;/p&gt;

&lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; [ID]
      ,[Descrizione]
      ,[Prezzo]
      ,[Quantità]
      ,[Umi]
      ,IsNull(AltGuid, dbo.Guid_EMPTY()) &lt;span class="kwrd"&gt;AS&lt;/span&gt; Alt
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; [paperinik].[dbo].[TbRighe]&lt;/pre&gt;

&lt;p&gt;The query produces the following output:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/HowtocreateaGuid.EmptyinSQL_141CA/guidquery_2.jpg" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="guidquery" border="0" alt="guidquery" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/HowtocreateaGuid.EmptyinSQL_141CA/guidquery_thumb.jpg" width="644" height="104" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I can use it also to build a query like the one below:&lt;/p&gt;

&lt;pre class="TsqlFormat"&gt;&lt;span class="kwrd"&gt;SELECT&lt;/span&gt; [ID]
      ,[Descrizione]
      ,[Prezzo]
      ,[Quantità]
      ,[Umi]
      ,IsNull(AltGuid, dbo.Guid_EMPTY()) &lt;span class="kwrd"&gt;AS&lt;/span&gt; Alt
  &lt;span class="kwrd"&gt;FROM&lt;/span&gt; [paperinik].[dbo].[TbRighe]
&lt;span class="kwrd"&gt;WHERE&lt;/span&gt;
IsNull(AltGuid, dbo.Guid_EMPTY()) = dbo.Guid_EMPTY()&lt;/pre&gt;

&lt;p&gt;That allows me to filter only the Guid Empty rows, or I can use the &amp;lt;&amp;gt; to find only the rows with a non Empty Guid. This way of writing the query, is giving me the possibility to use Guid.Empty in my Code as a SQLParameter value without the need to use a Nullable Guid or to implement complicated control expressions in my C# classes.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:06fc812e-6fbb-411a-9fb5-c5c256bbe9e0" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/SQL" rel="tag"&gt;SQL&lt;/a&gt;,&lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Guid" rel="tag"&gt;Guid&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/484.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/08/10/how-to-create-a-guid.empty-in-sql.aspx</guid>
            <pubDate>Tue, 10 Aug 2010 20:53:20 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/484.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/08/10/how-to-create-a-guid.empty-in-sql.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/484.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Access the Deleted Rows of a Datatable</title>
            <category>Winforms Development</category>
            <category>Data and Business Logic Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/08/09/access-the-deleted-rows-of-a-datatable.aspx</link>
            <description>&lt;p&gt;Today, I’m updating the Code Generator I’ve made in 2006 to build automatically the Data Provider classes for my applications. I’m passing my applications to Framework 4.0 and instead of a simple framework change, I’ve decided to make some cleaning in Old Common Libraries code and add some new features in the Data Classes.&lt;/p&gt;  &lt;p&gt;One of the new features in my data classes, will be some events, raised when data operations complete, RowAdded and RowDeleted events are two of them. In both cases, it would probably be useful if you Handle the Event in your code, to have some informations on the Added Row or Deleted Row, so I decided to pass the whole DataRow as a property of the event argument.&lt;/p&gt;  &lt;p&gt;Pass the Added row as an argument is very simple, I have the object in my method.&lt;/p&gt;  &lt;p&gt;Pass the Deleted row is a little less simple. I’ve made a simple test project to find out how to get it, to be precise, the exact phrase is: &lt;em&gt;How to get a copy of it&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;The sample form is the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/AccesstheDeletedRowsofaDatatable_EFEB/righecancellate_2.jpg" rel="lightbox"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="righecancellate" border="0" alt="righecancellate" src="http://community.dotnetwork.it/images/community_dotnetwork_it/Excentric/WindowsLiveWriter/AccesstheDeletedRowsofaDatatable_EFEB/righecancellate_thumb.jpg" width="244" height="184" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;On the form there are 3 buttons – Carica = Load, Test Aggiunta = Test AddRow, Test cancellazione = Test Deletion. There is also a textbox, set as Multiline with vertical scrollbar.&lt;/p&gt;  &lt;p&gt;The test code is the following:&lt;/p&gt;  &lt;pre class="CSharpFormat"&gt;        DataTable mDt;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FLD_ID = &lt;span class="str"&gt;"ID"&lt;/span&gt;;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FLD_Description = &lt;span class="str"&gt;"Description"&lt;/span&gt;;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FLD_Date = &lt;span class="str"&gt;"Date"&lt;/span&gt;;
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FLD_Price = &lt;span class="str"&gt;"Price"&lt;/span&gt;;

        &lt;span class="kwrd"&gt;public&lt;/span&gt; Form1()
        {
            InitializeComponent();
            mDt = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataTable(&lt;span class="str"&gt;"Tbtest"&lt;/span&gt;);
            DataColumn col = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataColumn(FLD_ID, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;int&lt;/span&gt;));
            col.AutoIncrement = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            col.AutoIncrementSeed = 1;
            col.AutoIncrementStep = 1;
            mDt.Columns.Add(col);
            col = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataColumn(FLD_Description, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;));
            mDt.Columns.Add(col);
            col = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataColumn(FLD_Date, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(DateTime));
            mDt.Columns.Add(col);
            col = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataColumn(FLD_Price, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Decimal));
            mDt.Columns.Add(col);
        }&lt;/pre&gt;

&lt;p&gt;The initialization code, I build a Datatable on the Constructor code of the form.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnCarica_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            mDt.Rows.Clear();

            DataRow row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Quaderno"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 1.5;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Penna"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 2.8;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Gomma"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 0.7;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Matita"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 1.1;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Block notes"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 2.8;
            mDt.Rows.Add(row);

            row = mDt.NewRow();
            row[FLD_Description] = &lt;span class="str"&gt;"Pennarelli 12 colori"&lt;/span&gt;;
            row[FLD_Date] = DateTime.Now;
            row[FLD_Price] = 6.7;
            mDt.Rows.Add(row);

            mDt.AcceptChanges();

            Mostra();
        }&lt;/pre&gt;

&lt;p&gt;Here I build some rows, put them in the DataTable and call the Mostra method, wich shows the rows in the textbox.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Mostra()
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Empty;
            &lt;span class="kwrd"&gt;for&lt;/span&gt;( &lt;span class="kwrd"&gt;int&lt;/span&gt; i=0; i&amp;lt; mDt.Rows.Count;i++)
            {
                MostraRiga(mDt.Rows[i]);
            }
    
        }

        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; MostraRiga(DataRow pRow)
        {
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += &lt;span class="str"&gt;"ID: "&lt;/span&gt; + pRow[FLD_ID].ToString() + Environment.NewLine;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += &lt;span class="str"&gt;"Description: "&lt;/span&gt; + pRow[FLD_Description].ToString() + Environment.NewLine;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += &lt;span class="str"&gt;"Date: "&lt;/span&gt; + pRow[FLD_Date].ToString() + Environment.NewLine;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += &lt;span class="str"&gt;"Price: "&lt;/span&gt; + pRow[FLD_Price].ToString() + Environment.NewLine;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;.txtResult.Text += Environment.NewLine;
        }&lt;/pre&gt;

&lt;p&gt;This is the Mostra method and the MostraRiga Method, made to show the content of the table rows on the textbox.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnAdd_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {

            DataRow row = mDt.NewRow();
            mDt.Rows.Add(row);
            row[FLD_Description] = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"Nuova riga {0}"&lt;/span&gt;, row[FLD_ID]);
            row[FLD_Date] = DateTime.Now;
            &lt;span class="kwrd"&gt;decimal&lt;/span&gt; pippo = Convert.ToDecimal(row[FLD_ID]);
            row[FLD_Price] = pippo*0.98m;

            mDt.AcceptChanges();

            MostraRiga(row);
        }&lt;/pre&gt;

&lt;p&gt;Here is the AddRow test, that simply builds a row, adds it to the table and then shows it on the textbox.&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; btnDelete_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
        {
            DataRow row = mDt.Rows[0];
            &lt;span class="kwrd"&gt;int&lt;/span&gt; id = Convert.ToInt32(row[FLD_ID]);
            row.Delete();
            &lt;span class="kwrd"&gt;string&lt;/span&gt; filter = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"{0} = {1}"&lt;/span&gt;, FLD_ID, id);
            DataView vi = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataView(mDt, filter,&lt;span class="str"&gt;""&lt;/span&gt;, DataViewRowState.Deleted);
            DataTable tt = vi.ToTable();
            mDt.AcceptChanges();
            MostraRiga(tt.Rows[0]);
        }&lt;/pre&gt;

&lt;p&gt;And finally the most important bit of code, the code that helps us to show the informations of the deleted row.
  &lt;br /&gt;As you can see, the method simply deletes the first row of the DataTable, saving it’s ID. 

  &lt;br /&gt;After the deletion, to be able to get the whole row, I build a dataview that retrieves the row I’ve deleted and then uses the ToTable method of the DataView to put the data in a new Table. Then I give the Row to the MostraRiga (ShowRow) method and I can see its content on my textbox.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;font color="#ff0000"&gt;ToTable &lt;/font&gt;&lt;/strong&gt;passage is very important, because if you try to pass to the function something like:&lt;/p&gt;

&lt;pre class="CSharpFormat"&gt;MostraRiga(vi[0].Row);&lt;/pre&gt;

&lt;p&gt;Whichis perfectly legal with a non deleted row, you instead receive an Exception, because you cannot access deleted rows data.&lt;/p&gt;

&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:17113bfd-eb5e-4299-8c45-1632c622454a" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DataTable" rel="tag"&gt;DataTable&lt;/a&gt;,&lt;a href="http://technorati.com/tags/DataView" rel="tag"&gt;DataView&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Deleted+Rows" rel="tag"&gt;Deleted Rows&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/482.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/08/09/access-the-deleted-rows-of-a-datatable.aspx</guid>
            <pubDate>Mon, 09 Aug 2010 15:03:42 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/482.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/08/09/access-the-deleted-rows-of-a-datatable.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/482.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How to create the ASP.NET 2.0 authentication tables on a SQL Server DB</title>
            <category>Web Development</category>
            <link>http://community.dotnetwork.it/Excentric/archive/2010/08/01/how-to-create-the-asp.net-2.0-authentication-tables-on-a.aspx</link>
            <description>&lt;p&gt;The translation of this post is very simple, because I am not enough fluent in english to write what I wrote in italian, but I just write something to the beginners, the newbies to a new technology. Never stop in front of an obstacle, in our business we got the luck that almost everything has already been solved by someone else. So F1, or Google, or BING or a forum are always not far from you.&lt;/p&gt;  &lt;p&gt;My problem, being a beginner in ASP.Net MVC was simple, the base template of this technology in Visual Studio, creates me a fully functional website to experiment with, but even though there is a nice Registration Form and Login Form, they don’t work, because they need that in your database you have a precise schema of tables and stored procedures to make things work.&lt;/p&gt;  &lt;p&gt;The solution is a small utility installed by the .Net framework 2.0 in his folder.&lt;/p&gt;  &lt;p&gt;I found this article: &lt;a title="Creating the Membership Schema in SQL Server" href="http://www.asp.net/security/tutorials/creating-the-membership-schema-in-sql-server-cs" target="_blank"&gt;Creating the Membership Schema in SQL Server&lt;/a&gt;, (which was on the ASP.Net, the same where I can find tutorials on MVC) where it is explained not only how to build the tables using the RUN command: &lt;code&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;%WINDIR%\Microsoft.Net\Framework\v2.0.50727\aspnet_regsql.exe&lt;/strong&gt;&lt;/font&gt;&lt;/code&gt; that runs a nice wizard that creates or removes the authentication tables on a SQL Server database, but it explains also how the authentication system works. After the creation of the tables and the set up of the connection string of my web application to the database, the ASP.Net MVC basic site has full registration and login functionalities.&lt;/p&gt;  &lt;p&gt;Maybe for those who work with ASP.Net 2.0 from the beginning this thing is probably obvious and elementary. But for a beginner starting with a new technology existing from a long time, usually the first steps are the highest to climb. For me step one is done, now let’s try the step 2.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:74752450-13d6-474e-95bf-d604067af260" class="wlWriterEditableSmartContent"&gt;Technorati Tag: &lt;a href="http://technorati.com/tags/ASP.NET+MVC" rel="tag"&gt;ASP.NET MVC&lt;/a&gt;,&lt;a href="http://technorati.com/tags/authentication" rel="tag"&gt;authentication&lt;/a&gt;,&lt;a href="http://technorati.com/tags/membership" rel="tag"&gt;membership&lt;/a&gt;,&lt;a href="http://technorati.com/tags/create+security+schema" rel="tag"&gt;create security schema&lt;/a&gt;,&lt;a href="http://technorati.com/tags/SQL" rel="tag"&gt;SQL&lt;/a&gt;&lt;/div&gt;&lt;img src="http://community.dotnetwork.it/Excentric/aggbug/481.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sabrina C.</dc:creator>
            <guid>http://community.dotnetwork.it/Excentric/archive/2010/08/01/how-to-create-the-asp.net-2.0-authentication-tables-on-a.aspx</guid>
            <pubDate>Sun, 01 Aug 2010 09:07:07 GMT</pubDate>
            <wfw:comment>http://community.dotnetwork.it/Excentric/comments/481.aspx</wfw:comment>
            <comments>http://community.dotnetwork.it/Excentric/archive/2010/08/01/how-to-create-the-asp.net-2.0-authentication-tables-on-a.aspx#feedback</comments>
            <wfw:commentRss>http://community.dotnetwork.it/Excentric/comments/commentRss/481.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
