<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" 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:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>My thoughts, shares ... with .Net and Microsoft</title>
    <link>http://blog.svencipido.be/Blog/</link>
    <description>My life in the Microsoft World</description>
    <copyright>Sven Cipido</copyright>
    <lastBuildDate>Wed, 19 Dec 2007 13:58:17 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.8.5223.0</generator>
    <managingEditor>sccs@svencipido.be</managingEditor>
    <webMaster>sccs@svencipido.be</webMaster>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=d2b370d1-85f0-417c-aa34-ee32f0b103d6</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,d2b370d1-85f0-417c-aa34-ee32f0b103d6.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,d2b370d1-85f0-417c-aa34-ee32f0b103d6.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=d2b370d1-85f0-417c-aa34-ee32f0b103d6</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      For a project I did using VSTO, we need to have strong named assemblies when deploying
      our VSTO application.
   </p>
        <p>
      Now we have one 3rd party assembly which is not strong named.
   </p>
        <p>
      So how could you make a 3rd party assembly strong named for your project ?
   </p>
        <p>
      It’s very easy and it only takes 2 command line commandos:
   </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ILDASM
      /<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">out</span>:asm.il
      asm.dll<br />
      ILASM asm.il /KEY=key.snk /DLL /OUTPUT=asm.dll</span>
        </p>
        <p>
      With these parameters
   </p>
        <ul>
          <li>
         Asm.dll is your dll to sign 
      </li>
          <li>
         Key.snk is your key</li>
        </ul>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=d2b370d1-85f0-417c-aa34-ee32f0b103d6" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Strong naming of 3rd party assemblies</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,d2b370d1-85f0-417c-aa34-ee32f0b103d6.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Strong+Naming+Of+3rd+Party+Assemblies.aspx</link>
      <pubDate>Wed, 19 Dec 2007 13:58:17 GMT</pubDate>
      <description>&lt;p&gt;
   For a project I did using VSTO, we need to have strong named assemblies when deploying
   our VSTO application.
&lt;/p&gt;
&lt;p&gt;
   Now we have one 3rd party assembly which&amp;nbsp;is not strong named.
&lt;/p&gt;
&lt;p&gt;
   So how could you make a 3rd party assembly strong named for your project ?
&lt;/p&gt;
&lt;p&gt;
   It’s very easy and it only takes 2 command line commandos:
&lt;/p&gt;
&lt;p&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ILDASM
   /&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;out&lt;/span&gt;:asm.il
   asm.dll&lt;br&gt;
   ILASM asm.il /KEY=key.snk /DLL /OUTPUT=asm.dll&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   With these parameters
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      Asm.dll is your dll to sign 
   &lt;li&gt;
      Key.snk is your key&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=d2b370d1-85f0-417c-aa34-ee32f0b103d6" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,d2b370d1-85f0-417c-aa34-ee32f0b103d6.aspx</comments>
      <category>.Net 2.0;VSTO</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=b0794ba5-35c3-4e36-bd0a-44d66a70d719</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,b0794ba5-35c3-4e36-bd0a-44d66a70d719.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,b0794ba5-35c3-4e36-bd0a-44d66a70d719.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=b0794ba5-35c3-4e36-bd0a-44d66a70d719</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Everyone knows Snag-it, the great capturing tool of <a href="http://www.techsmith.com/camtasia.asp">Camtasia</a>. 
      I think that a lot of developers use this tool to make screen captures.
   </p>
        <p>
      Well these guys gives us a nice plugin for VSTS.  After you have installed this
      plugin, you can easily add a screenshot to your work items in VSTS.  It's just
      great :-).
   </p>
        <p>
      You can download it <a href="http://www.techsmith.com/snagit/accessories/teamsystem.asp">here</a>.
      If you want to see it working before installing just watch <a href="http://video.techsmith.com/snagit/accessories/teamsystem/enu/teamsystem.html">this
      video</a>.
   </p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=b0794ba5-35c3-4e36-bd0a-44d66a70d719" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Nice and handy plugin for Visual Studio Team System</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,b0794ba5-35c3-4e36-bd0a-44d66a70d719.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Nice+And+Handy+Plugin+For+Visual+Studio+Team+System.aspx</link>
      <pubDate>Wed, 03 Oct 2007 07:15:50 GMT</pubDate>
      <description>&lt;p&gt;
   Everyone knows Snag-it, the great capturing tool of &lt;a href="http://www.techsmith.com/camtasia.asp"&gt;Camtasia&lt;/a&gt;.&amp;nbsp;
   I think that a lot of developers use this tool to make screen captures.
&lt;/p&gt;
&lt;p&gt;
   Well these guys gives us a nice plugin for VSTS.&amp;nbsp; After you have installed this
   plugin, you can easily add a screenshot to your work items in VSTS.&amp;nbsp; It's just
   great :-).
&lt;/p&gt;
&lt;p&gt;
   You can download it &lt;a href="http://www.techsmith.com/snagit/accessories/teamsystem.asp"&gt;here&lt;/a&gt;.
   If you want to see it working before installing just watch &lt;a href="http://video.techsmith.com/snagit/accessories/teamsystem/enu/teamsystem.html"&gt;this
   video&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=b0794ba5-35c3-4e36-bd0a-44d66a70d719" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,b0794ba5-35c3-4e36-bd0a-44d66a70d719.aspx</comments>
      <category>.Net 2.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=4f21cb9f-c334-42b7-ae5e-6d9d5f3db9d1</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,4f21cb9f-c334-42b7-ae5e-6d9d5f3db9d1.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,4f21cb9f-c334-42b7-ae5e-6d9d5f3db9d1.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=4f21cb9f-c334-42b7-ae5e-6d9d5f3db9d1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      A colleague on my current project asked me how he could set very fast the correct
      tab order in a Win Form, as this seems different to VS2003.
   </p>
        <p>
      It’s simple, follow these steps
   </p>
        <ol>
          <li>
         Open your Win Form 
      </li>
          <li>
         Under the View menu or in the menu bar you will find the Tab Order option.  If
         it’s not enabled, you select all your controls.<br /><img src="http://blog.svencipido.be/Blog/content/binary/taborder1.jpg" border="0" /><br /></li>
          <li>
         Then your screen will look like this 
         <br /><img src="http://blog.svencipido.be/Blog/content/binary/taborder2.jpg" border="0" /><br /></li>
          <li>
         Now you can click on the controls to set the tab order.</li>
        </ol>
        <p>
      This is the new result.
   </p>
        <p>
          <img src="http://blog.svencipido.be/Blog/content/binary/taborder3.jpg" border="0" />
        </p>
        <p>
      This is a very fast way to set your tab order. BTW : If you have numbered you control
      to far, just keep clicking.  When the number of controls is reached, the taborder
      will start over at 0, so you can just cycle then till you have the correct tab order.
   </p>
        <p>
      Keep in mind; the labels have also a tab order but VS removes the tab order of them. 
      Only when you use hotkeys, the tab order of the labels is also important.
   </p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=4f21cb9f-c334-42b7-ae5e-6d9d5f3db9d1" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Tab order in VS2005</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,4f21cb9f-c334-42b7-ae5e-6d9d5f3db9d1.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Tab+Order+In+VS2005.aspx</link>
      <pubDate>Fri, 27 Jul 2007 08:35:18 GMT</pubDate>
      <description>&lt;p&gt;
   A colleague on my current project asked me how he could set very fast the correct
   tab order in a Win Form, as this seems different to VS2003.
&lt;/p&gt;
&lt;p&gt;
   It’s simple, follow these steps
&lt;/p&gt;
&lt;ol&gt;
   &lt;li&gt;
      Open your Win Form 
   &lt;li&gt;
      Under the View menu or in the menu bar you will find the Tab Order option.&amp;nbsp; If
      it’s not enabled, you select all your controls.&lt;br&gt;
      &lt;img src="http://blog.svencipido.be/Blog/content/binary/taborder1.jpg" border=0&gt;
      &lt;br&gt;
   &lt;li&gt;
      Then your screen will look like this 
      &lt;br&gt;
      &lt;img src="http://blog.svencipido.be/Blog/content/binary/taborder2.jpg" border=0&gt;
      &lt;br&gt;
   &lt;li&gt;
      Now you can click on the controls to set the tab order.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
   This is the new result.
&lt;/p&gt;
&lt;p&gt;
   &lt;img src="http://blog.svencipido.be/Blog/content/binary/taborder3.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
   This is a very fast way to set your tab order. BTW : If you have numbered you control
   to far, just keep clicking.&amp;nbsp; When the number of controls is reached, the taborder
   will start over at 0, so you can just cycle then till you have the correct tab order.
&lt;/p&gt;
&lt;p&gt;
   Keep in mind; the labels have also a tab order but VS removes the tab order of them.&amp;nbsp;
   Only when you use hotkeys, the tab order of the labels is also important.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=4f21cb9f-c334-42b7-ae5e-6d9d5f3db9d1" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,4f21cb9f-c334-42b7-ae5e-6d9d5f3db9d1.aspx</comments>
      <category>.Net 2.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=a0068d3d-6166-47e0-a779-d7fe40b1e697</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,a0068d3d-6166-47e0-a779-d7fe40b1e697.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,a0068d3d-6166-47e0-a779-d7fe40b1e697.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=a0068d3d-6166-47e0-a779-d7fe40b1e697</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I just found a strange label behaviour in VS2005.  When I add a label on my winform
      and I add the text to it where we use rounded brackets, the closing rounded bracket
      isn't showed and at the beginning of text another opening rounded bracket is showed.
   </p>
        <p>
          <img src="http://blog.svencipido.be/Blog/content/binary/LabelbehaviourProperties.jpg" border="0" />
          <br />
          <strong>
            <font size="1">The properties of the label.</font>
          </strong>
        </p>
        <p>
          <img src="http://blog.svencipido.be/Blog/content/binary/LabelbehaviourResult.jpg" border="0" />
          <br />
          <font size="1">
            <strong>The result on the label</strong>
          </font>
        </p>
        <p>
      The most strange thing is that it's only in the project where I'm currently working
      and they don't have their own label control.
   </p>
        <p>
      After checking out more it's also with the "/" character.
   </p>
        <p>
      Don't know what it is, but it's irritating.
   </p>
        <p>
          <em>Update : this behaviour is only when you use the property RightToLeft = true and
      the combination of Autosize = false.  It seems that this is a bug.  Don't
      have found a solution for it. But a collegue of me has reproduced this bug.</em>
        </p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=a0068d3d-6166-47e0-a779-d7fe40b1e697" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Strange label behaviour in VS2005</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,a0068d3d-6166-47e0-a779-d7fe40b1e697.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Strange+Label+Behaviour+In+VS2005.aspx</link>
      <pubDate>Fri, 06 Jul 2007 08:03:44 GMT</pubDate>
      <description>&lt;p&gt;
   I just found a strange label behaviour in VS2005.&amp;nbsp; When I add a label on my winform
   and I add the text to it where we use rounded brackets, the closing rounded bracket
   isn't showed and at the beginning of text another opening rounded bracket is showed.
&lt;/p&gt;
&lt;p&gt;
   &lt;img src="http://blog.svencipido.be/Blog/content/binary/LabelbehaviourProperties.jpg" border=0&gt;
   &lt;br&gt;
   &lt;strong&gt;&lt;font size=1&gt;The properties of the label.&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
   &lt;img src="http://blog.svencipido.be/Blog/content/binary/LabelbehaviourResult.jpg" border=0&gt;
   &lt;br&gt;
   &lt;font size=1&gt;&lt;strong&gt;The result on the label&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
   The most strange thing is that it's only in the project where I'm currently working
   and they don't have their own label control.
&lt;/p&gt;
&lt;p&gt;
   After checking out more it's also with the "/" character.
&lt;/p&gt;
&lt;p&gt;
   Don't know what it is, but it's irritating.
&lt;/p&gt;
&lt;p&gt;
   &lt;em&gt;Update : this behaviour is only when you use the property RightToLeft = true and
   the combination of Autosize = false.&amp;nbsp; It seems that this is a bug.&amp;nbsp; Don't
   have found a solution for it. But a collegue of me has reproduced this bug.&lt;/em&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=a0068d3d-6166-47e0-a779-d7fe40b1e697" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,a0068d3d-6166-47e0-a779-d7fe40b1e697.aspx</comments>
      <category>.Net 2.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=9ce11d2b-cd63-4131-bd30-783efdb1e728</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,9ce11d2b-cd63-4131-bd30-783efdb1e728.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,9ce11d2b-cd63-4131-bd30-783efdb1e728.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9ce11d2b-cd63-4131-bd30-783efdb1e728</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
      For a project I'm currently working on, we need a service that send on regular base
      a signal to a certain system, this service can't be hosted in IIS and we need to use
      a windows service because the Windows Service can continuously send that signal. This
      service uses an httplistener to receive the soap messages from clients and parses
      the incoming SOAP to get the data. This simulates the IIS so soap calls can be send
      through HTTP, clients are not aware of the fact that they are not talking to IIS.
      This concept allows keeping sending the heartbeats while processing the soaprequest. 
   </p>
        <p>
      But what about the WSDL ? Normally developers can ask the WSDL so they can create
      the proxies for their clients.<br />
      This is an issue, as the service is not an IIS service, we need another way to solve
      this problem. You can do this using this technology : 
   </p>
        <p>
      The contract is developed as webservice without implementation. This results in a
      .cs file which declares the webmethods, but holds no functionality and an .asmx file.
      The HTTP listener can forward the call for the WSDL to the ASP.NET environment which
      generates the WSDL. The ASP.NET environment processes the .asmx?WSDL query and generates
      the WSDL. This WSDL is send to the client development environment so proxies can be
      generated. 
   </p>
        <p>
      This whole description is fine, but practical ?<br />
      OK, this is my best practice. In my solution I create a webservice project. In this
      project I write all the code I so that my WS will work. 
   </p>
        <p>
        </p>
        <p>
          <font face="Courier New" size="2">public Service () { </font>
        </p>
        <p>
          <font face="Courier New" size="2">//Uncomment the following line if using designed
      components 
      <br />
      //InitializeComponent(); 
      <br />
      } </font>
        </p>
        <p>
          <font face="Courier New" size="2">[WebMethod]<br />
      public OperationAnswer Add2Numbers(int number1, int number2) 
      <br />
      {<br />
      OperationAnswer a = new OperationAnswer();<br />
      a.ErrorCode = 0;<br />
      a.STBAnswer = "Het Antwoord" ; </font>
        </p>
        <p>
          <font face="Courier New" size="2">return a;<br />
      } </font>
        </p>
        <p>
          <font face="Courier New" size="2">#region Answer Classes<br />
      //Temp class<br />
      public class OperationAnswer<br />
      {<br />
      private int _ErrorCode;<br />
      public int ErrorCode<br />
      {<br />
      get { return _ErrorCode; }<br />
      set { _ErrorCode = value; }<br />
      }<br />
      private String _STBAnswer;<br />
      public String STBAnswer<br />
      {<br />
      get { return _STBAnswer; }<br />
      set { _STBAnswer = value; }<br />
      }<br />
      }<br />
      #endregion</font>
        </p>
        <p>
      After that I go to the bin directory of my windows service. In here I copy the asmx
      file and create a directory named App_Code. In this directory I copy the .cs file
      of the webservice. Now that we have done this, our webservice is hosted in our windows
      service without using IIS. 
   </p>
        <p>
      But what about the WSDL ? Here for I have created a new project called processingHost.
      In here we have a method that will create a stringwriter and return the value of this.
      The content contains the WSDL. 
   </p>
        <p>
          <font face="Courier New" size="2">[Serializable]<br />
      public class ProcessingHost : MarshalByRefObject<br />
      {<br />
      public string ProcessRequest(string page, string query)<br />
      {<br />
      System.IO.StringWriter sw = new System.IO.StringWriter(); </font>
        </p>
        <p>
          <font face="Courier New" size="2">HttpRuntime.ProcessRequest(new SimpleWorkerRequest(page,
      query, sw)); </font>
        </p>
        <p>
          <font face="Courier New" size="2">sw.Close();<br />
      return sw.ToString();<br />
      } </font>
        </p>
        <p>
      This DLL must also copied to your service. So in the bin dir of your service create
      a new bin directory and copy the DLL in here.<br />
      When using this in your service the moment the client ask the WSDL, you can use this
      code : 
   </p>
        <p>
          <font face="Courier New" size="2">static ProcessingHost SOAPProcessingHost;<br />
      static HttpListener SoapHTTPListener;<br />
      static HttpListenerContext SoapHTTPListenerContext; </font>
        </p>
        <p>
          <font face="Courier New" size="2">SOAPProcessingHost = (ProcessingHost)ApplicationHost.CreateApplicationHost(typeof(ProcessingHost),"/",Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules(false)[0].FullyQualifiedName)); </font>
        </p>
        <p>
          <font face="Courier New" size="2">//Create a new HTTPListener<br />
      SoapHTTPListener = new HttpListener(); </font>
        </p>
        <p>
          <font face="Courier New" size="2">string SoapServer = "</font>
          <a href="http://localhost:9999/&quot;;">
            <font face="Courier New" size="2">http://localhost:9999/"</font>
          </a>
        </p>
        <p>
          <font face="Courier New" size="2">SoapHTTPListener.Prefixes.Add(SoapServer); </font>
        </p>
        <p>
          <font face="Courier New" size="2">//Start the listener<br />
      SoapHTTPListener.Start(); </font>
        </p>
        <p>
          <font face="Courier New" size="2">while (SoapHTTPListener.IsListening)<br />
      { </font>
        </p>
        <p>
          <font face="Courier New" size="2">//Get the SOAP Enveloppe<br />
      SoapHTTPListenerContext = SoapHTTPListener.GetContext();<br />
      string page = SoapHTTPListenerContext.Request.Url.LocalPath.Replace("/", "");<br />
      string query = SoapHTTPListenerContext.Request.Url.Query.Replace("?", ""); </font>
        </p>
        <p>
          <font face="Courier New" size="2">if (query.ToUpper() == "WSDL")<br />
      {<br />
      string Answer = SOAPProcessingHost.ProcessRequest(page, query);<br />
      if (Answer != null &amp;&amp; SoapHTTPListenerContext.Response.OutputStream.CanWrite)<br />
      {<br />
      byte[] AnswerAsByteArray = System.Text.UTF8Encoding.UTF8.GetBytes(Answer);<br />
      SoapHTTPListenerContext.Response.OutputStream.Write(AnswerAsByteArray,0, AnswerAsByteArray.Length);<br />
      }<br />
      }<br />
      else<br />
      {<br />
      //Do your normal SOAP processing here<br />
      }<br />
      SoapHTTPListenerContext.Response.Close(); </font>
        </p>
        <p>
          <font face="Courier New" size="2">}</font>
        </p>
        <p>
      Now when your service is running, the developers of the client can create a webreference
      to the service by using following statement : 
   </p>
        <p>
      http://localhost:9999/Service.asmx?WSDL 
   </p>
        <p>
      You can download <a href="http://blog.svencipido.be/Blog/content/binary/WebserviceWinserviceExample.zip">here
      a zipfile</a> which contains a small example project (quick and dirty coding). This
      project has a Soap client where you can enter 2 numbers, after pressing the "add"
      button, you get the result back. This soapclient calls the webservice hosted under
      a winservice without using IIS. The webservice code is also included. The windows
      service is sending a "heartbeat" (Text to the console) while waiting for SOAP input.
      This Heartbeat simulates another process that the windows service is doing. You can
      use this as an example for your project.
   </p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=9ce11d2b-cd63-4131-bd30-783efdb1e728" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>How to host an asmx in a windows service without using IIS ?</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,9ce11d2b-cd63-4131-bd30-783efdb1e728.aspx</guid>
      <link>http://blog.svencipido.be/Blog/How+To+Host+An+Asmx+In+A+Windows+Service+Without+Using+IIS+.aspx</link>
      <pubDate>Thu, 19 Apr 2007 20:25:48 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
   For a project I'm currently working on, we need a service that send on regular base
   a signal to a certain system, this service can't be hosted in IIS and we need to use
   a windows service because the Windows Service can continuously send that signal. This
   service uses an httplistener to receive the soap messages from clients and parses
   the incoming SOAP to get the data. This simulates the IIS so soap calls can be send
   through HTTP, clients are not aware of the fact that they are not talking to IIS.
   This concept allows keeping sending the heartbeats while processing the soaprequest. 
&lt;p&gt;
   But what about the WSDL ? Normally developers can ask the WSDL so they can create
   the proxies for their clients.&lt;br&gt;
   This is an issue, as the service is not an IIS service, we need another way to solve
   this problem. You can do this using this technology : 
&lt;p&gt;
   The contract is developed as webservice without implementation. This results in a
   .cs file which declares the webmethods, but holds no functionality and an .asmx file.
   The HTTP listener can forward the call for the WSDL to the ASP.NET environment which
   generates the WSDL. The ASP.NET environment processes the .asmx?WSDL query and generates
   the WSDL. This WSDL is send to the client development environment so proxies can be
   generated. 
&lt;p&gt;
   This whole description is fine, but practical ?&lt;br&gt;
   OK, this is my best practice. In my solution I create a webservice project. In this
   project I write all the code I so that my WS will work. 
&lt;p&gt;
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;public Service () { &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;//Uncomment the following line if using designed components 
   &lt;br&gt;
   //InitializeComponent(); 
   &lt;br&gt;
   } &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;[WebMethod]&lt;br&gt;
   public OperationAnswer Add2Numbers(int number1, int number2) 
   &lt;br&gt;
   {&lt;br&gt;
   OperationAnswer a = new OperationAnswer();&lt;br&gt;
   a.ErrorCode = 0;&lt;br&gt;
   a.STBAnswer = "Het Antwoord" ; &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;return a;&lt;br&gt;
   } &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;#region Answer Classes&lt;br&gt;
   //Temp class&lt;br&gt;
   public class OperationAnswer&lt;br&gt;
   {&lt;br&gt;
   private int _ErrorCode;&lt;br&gt;
   public int ErrorCode&lt;br&gt;
   {&lt;br&gt;
   get { return _ErrorCode; }&lt;br&gt;
   set { _ErrorCode = value; }&lt;br&gt;
   }&lt;br&gt;
   private String _STBAnswer;&lt;br&gt;
   public String STBAnswer&lt;br&gt;
   {&lt;br&gt;
   get { return _STBAnswer; }&lt;br&gt;
   set { _STBAnswer = value; }&lt;br&gt;
   }&lt;br&gt;
   }&lt;br&gt;
   #endregion&lt;/font&gt; 
&lt;p&gt;
   After that I go to the bin directory of my windows service. In here I copy the asmx
   file and create a directory named App_Code. In this directory I copy the .cs file
   of the webservice. Now that we have done this, our webservice is hosted in our windows
   service without using IIS. 
&lt;p&gt;
   But what about the WSDL ? Here for I have created a new project called processingHost.
   In here we have a method that will create a stringwriter and return the value of this.
   The content contains the WSDL. 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;[Serializable]&lt;br&gt;
   public class ProcessingHost : MarshalByRefObject&lt;br&gt;
   {&lt;br&gt;
   public string ProcessRequest(string page, string query)&lt;br&gt;
   {&lt;br&gt;
   System.IO.StringWriter sw = new System.IO.StringWriter(); &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;HttpRuntime.ProcessRequest(new SimpleWorkerRequest(page,
   query, sw)); &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;sw.Close();&lt;br&gt;
   return sw.ToString();&lt;br&gt;
   } &lt;/font&gt; 
&lt;p&gt;
   This DLL must also copied to your service. So in the bin dir of your service create
   a new bin directory and copy the DLL in here.&lt;br&gt;
   When using this in your service the moment the client ask the WSDL, you can use this
   code : 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;static ProcessingHost SOAPProcessingHost;&lt;br&gt;
   static HttpListener SoapHTTPListener;&lt;br&gt;
   static HttpListenerContext SoapHTTPListenerContext; &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;SOAPProcessingHost = (ProcessingHost)ApplicationHost.CreateApplicationHost(typeof(ProcessingHost),"/",Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules(false)[0].FullyQualifiedName)); &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;//Create a new HTTPListener&lt;br&gt;
   SoapHTTPListener = new HttpListener(); &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;string SoapServer = "&lt;/font&gt;&lt;a href='http://localhost:9999/";'&gt;&lt;font face="Courier New" size=2&gt;http://localhost:9999/"&lt;/font&gt;&lt;/a&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;SoapHTTPListener.Prefixes.Add(SoapServer); &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;//Start the listener&lt;br&gt;
   SoapHTTPListener.Start(); &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;while (SoapHTTPListener.IsListening)&lt;br&gt;
   { &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;//Get the SOAP Enveloppe&lt;br&gt;
   SoapHTTPListenerContext = SoapHTTPListener.GetContext();&lt;br&gt;
   string page = SoapHTTPListenerContext.Request.Url.LocalPath.Replace("/", "");&lt;br&gt;
   string query = SoapHTTPListenerContext.Request.Url.Query.Replace("?", ""); &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;if (query.ToUpper() == "WSDL")&lt;br&gt;
   {&lt;br&gt;
   string Answer = SOAPProcessingHost.ProcessRequest(page, query);&lt;br&gt;
   if (Answer != null &amp;amp;&amp;amp; SoapHTTPListenerContext.Response.OutputStream.CanWrite)&lt;br&gt;
   {&lt;br&gt;
   byte[] AnswerAsByteArray = System.Text.UTF8Encoding.UTF8.GetBytes(Answer);&lt;br&gt;
   SoapHTTPListenerContext.Response.OutputStream.Write(AnswerAsByteArray,0, AnswerAsByteArray.Length);&lt;br&gt;
   }&lt;br&gt;
   }&lt;br&gt;
   else&lt;br&gt;
   {&lt;br&gt;
   //Do your normal SOAP processing here&lt;br&gt;
   }&lt;br&gt;
   SoapHTTPListenerContext.Response.Close(); &lt;/font&gt; 
&lt;p&gt;
   &lt;font face="Courier New" size=2&gt;}&lt;/font&gt; 
&lt;p&gt;
   Now when your service is running, the developers of the client can create a webreference
   to the service by using following statement : 
&lt;p&gt;
   http://localhost:9999/Service.asmx?WSDL 
&lt;p&gt;
   You can download &lt;a href="http://blog.svencipido.be/Blog/content/binary/WebserviceWinserviceExample.zip"&gt;here
   a zipfile&lt;/a&gt; which contains a small example project (quick and dirty coding). This
   project has a Soap client where you can enter 2 numbers, after pressing the "add"
   button, you get the result back. This soapclient calls the webservice hosted under
   a winservice without using IIS. The webservice code is also included. The windows
   service is sending a "heartbeat" (Text to the console) while waiting for SOAP input.
   This Heartbeat simulates another process that the windows service is doing. You can
   use this as an example for your project.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=9ce11d2b-cd63-4131-bd30-783efdb1e728" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,9ce11d2b-cd63-4131-bd30-783efdb1e728.aspx</comments>
      <category>.Net 2.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=e2603465-d888-4028-b82a-552ca72458e6</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,e2603465-d888-4028-b82a-552ca72458e6.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,e2603465-d888-4028-b82a-552ca72458e6.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=e2603465-d888-4028-b82a-552ca72458e6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      I had reinstalled my PC, and I want to add my own code snippets back in VS2005, only
      they are located on a location that differs from the standard location for code snippets. 
      So normally you would go to the code snippet manager (Under the tools menu) and you
      can add your snippets from a different location. 
   </p>
        <p>
      But now the code snippet manager is missing in the tools menu.
   </p>
        <p>
      You can add the command back by going into Tools/Customize, Click on the Commands
      Tab, select the Tools Menu, and drag the Code Snippets Manager onto any command bar
      that you like.
   </p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=e2603465-d888-4028-b82a-552ca72458e6" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Code snippets in VS2005 - Part 3</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,e2603465-d888-4028-b82a-552ca72458e6.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Code+Snippets+In+VS2005++Part+3.aspx</link>
      <pubDate>Tue, 16 Jan 2007 09:18:47 GMT</pubDate>
      <description>&lt;p&gt;
   I had reinstalled my PC, and I want to add my own code snippets back in VS2005, only
   they are located on a location that differs from the standard location for code snippets.&amp;nbsp;
   So normally you would go to the code snippet manager (Under the tools menu) and you
   can add your snippets from a different location. 
&lt;/p&gt;
&lt;p&gt;
   But now the code snippet manager is missing in the tools menu.
&lt;/p&gt;
&lt;p&gt;
   You can add the command back by going into Tools/Customize, Click on the Commands
   Tab, select the Tools Menu, and drag the Code Snippets Manager onto any command bar
   that you like.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=e2603465-d888-4028-b82a-552ca72458e6" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,e2603465-d888-4028-b82a-552ca72458e6.aspx</comments>
      <category>.Net 2.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=f36e18ce-db03-48bb-a1e7-71bb67e51efe</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,f36e18ce-db03-48bb-a1e7-71bb67e51efe.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,f36e18ce-db03-48bb-a1e7-71bb67e51efe.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=f36e18ce-db03-48bb-a1e7-71bb67e51efe</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h3>Introduction
   </h3>
        <p>
      Why do you need them? We could give you a short answer about this.  When developing
      several projects in a company, you want them to have the same look.  So, just
      like me, for every new project you copy files, code, etc from a previous project. 
      The danger is that in the first place you forgot some items and then you have to add
      them later.
   </p>
        <p>
      This all takes up a lot of work.  You could help yourself and your team by creating
      a project template.  When this template is installed you can use it, just like
      when you start to create a new project with one of the standard templates.
   </p>
        <h3>VS2005 templates
   </h3>
        <p>
      First, let’s take a look where all the templates can be found.  The standard
      templates can be found at this location: C:\Program Files\Microsoft Visual Studio
      8\Common7\IDE\ProjectTemplates\Web\CSharp\1033 for the CSharp web templates.
   </p>
        <p>
      If you create your own templates they will be placed under: C:\Documents and Settings\&lt;User&gt;\My
      Documents\Visual Studio 2005\Templates.
   </p>
        <p>
      You can change the location of this.  To do so follow the next steps:
   </p>
        <ol>
          <li>
         Start VS2005 
      </li>
          <li>
         Go to Tools/Options 
      </li>
          <li>
         Expand Projects &amp; Solutions 
      </li>
          <li>
         Click on General 
      </li>
          <li>
         Make your changes for Visual Studio user Project Templates location and Visual Studio
         user Item Templates location</li>
        </ol>
        <h3>Difference between project and item templates
   </h3>
        <h4>Item template
   </h4>
        <p>
      An item template is an individual item that a user can add to a project by using the
      Add New Item dialog box.  
   </p>
        <h4>Project template
   </h4>
        <p>
      Project templates contain complete projects and can be added by the user with the
      New Project dialog box.
   </p>
        <h3>Inside a template
   </h3>
        <p>
      With this you could put the templates somewhere on a network drive and everyone connects
      to this drive.  So you won’t have to deploy the templates to every developer.
   </p>
        <p>
      When taking a closer look to the standard templates, you see that a template exists
      of a zip file containing all the files needed to create your project/item.  The
      most important file is the .vstemplate.  This file contains the definition how
      your project should look.  This file contains several blocks
   </p>
        <ul>
          <li>
         TemplateData 
      </li>
          <li>
         TemplateContent 
      </li>
          <li>
         WizardExtension 
      </li>
          <li>
         WizardData</li>
        </ul>
        <p>
      At this moment I will only focus on the TemplateData and TemplateContent block. 
      So let’s take a closer look at them.
   </p>
        <h4>TemplateDate
   </h4>
        <p>
      This is the definition how the template is displayed in either New Project or Add
      New Item.<br />
      Several attributes can be set.  We list the most used.
   </p>
        <p>
      Name: Specifies the name of the template<br />
      Description: The description of the template<br />
      Icon: The icon that will be displayed<br />
      ProjectType: the category under which it will be appearing.  A Category could
      be CSharp, VisualBasic,…
   </p>
        <p>
      A full list can be found <a href="http://msdn2.microsoft.com/en-us/library/hy7dh5te(VS.80).aspx">here</a>.
   </p>
        <h4>TemplateContent
   </h4>
        <p>
      This block specifies the contents of the template.  This block doesn’t have any
      attributes, but has a few child elements.  With the child elements you could
      define your projects, references, project collections and more.
   </p>
        <p>
      Read the info <a href="http://msdn2.microsoft.com/en-us/library/zfkkzb88(VS.80).aspx">here</a>.
   </p>
        <h3>Create your template
   </h3>
        <p>
      When you have created templates in VS2003, you know it took a long time to go. If
      you don’t know how this is done, read more info <a href="http://msdn2.microsoft.com/en-us/library/zfkkzb88(VS.80).aspx">here</a>.
   </p>
        <p>
      From VS2005 it only takes a few steps to create your template.  We will explain
      the first steps and then split up in the two types of templates.
   </p>
        <h4>First steps
   </h4>
        <ul>
          <li>
         Create a new project of the type you want to create your template. 
      </li>
          <li>
         Change the project for your needs by adding your forms, classes, etc.<br />
          <img src="http://blog.svencipido.be/Blog/content/binary/solutionfortemplate1project.png" border="0" /></li>
          <li>
         Save the project 
      </li>
          <li>
         Go to file/Export template 
      </li>
          <li>
         A wizard pops up<br /><img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard1.png" border="0" /></li>
          <li>
         Now choose your template style and if you have more than one project defined, the
         project you want to export.</li>
        </ul>
        <h4>Project template
   </h4>
        <p>
      After choosing the project template you get the next step which leads you to this
      screen.<br /><img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard2.png" border="0" /></p>
        <p>
      Fill in all project items as described above.  If you check the automatically
      import the template into Visual Studio, you don’t have to copy manually your template
      in the user template folder.
   </p>
        <p>
      Press the finish button and your template will be generated.
   </p>
        <p>
      If you check now the template file, you will see the zip file, containing your exported
      project.
   </p>
        <h4>Item template
   </h4>
        <p>
      If you choose for the item template, you will get the following screen as next step.<br /><img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard3.png" border="0" /><br />
      Now check the item you want to export.  After pressing next you will get a new
      wizard screen.<br /><img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard4.png" border="0" /><br />
      On this screen you can add the references, if needed by your selected item. 
      Press again next and you will get the item properties wizard screen.<br /><img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard5.png" border="0" /></p>
        <p>
      Press finish to create your template.
   </p>
        <h4>I don’t see the export template menu item
   </h4>
        <p>
      It seems that sometimes the menu item isn’t visible.  If you follow the next
      steps the item will be available.
   </p>
        <ul>
          <li>
         Right click on the toolbar 
      </li>
          <li>
         Select Customize 
      </li>
          <li>
         Click on the command tab 
      </li>
          <li>
         Under Categories and select File 
      </li>
          <li>
         Under commands select Export Template 
      </li>
          <li>
         Drag this under File Menu</li>
        </ul>
        <h3>Use your templates
   </h3>
        <p>
      Now that we have our templates, we can use them.  Open Visual Studio and choose
      create new project.  You will get a screen like this
   </p>
        <p>
          <img src="http://blog.svencipido.be/Blog/content/binary/usetemplates1.png" border="0" />
        </p>
        <p>
      On the right side you will see a section My Templates where you find your project
      template.  Choose the template, give it a name and press OK. The project will
      be created.
   </p>
        <p>
      We also have created an item template.  Add a new item to your project. 
      You will see next screen. 
   </p>
        <p>
      -<img src="http://blog.svencipido.be/Blog/content/binary/usetemplates2.png" border="0" /></p>
        <p>
      Also here you will find a section My Templates.  Choose your template, give it
      a name and press OK.  The item is created in your project.
   </p>
        <h3>Customize your templates
   </h3>
        <p>
      All templates support parameters so you could replace class names, namespaces,… on
      the moment the template is initiated.  These parameters are replaced by the wizard,
      the moment the user clicks OK on the New Project or Add New Item.
   </p>
        <p>
      A list of all reserved parameters can be found <a href="http://msdn2.microsoft.com/en-us/library/eehb4faa(vs.80).aspx">here</a>.
   </p>
        <h3>Multi-project templates
   </h3>
        <p>
      Multi project templates are in fact containers for 2 or more projects.  When
      choosing the template in the New Project dialog box, a solution with all included
      projects is created.
   </p>
        <p>
      In common a multi-project template is almost built in the same way as a project template. 
      It exists out of
   </p>
        <ul>
          <li>
         All projects 
      </li>
          <li>
         Each project has its own .vstemplate file 
      </li>
          <li>
         1 root .vstemplate file</li>
        </ul>
        <p>
      The root .vstemplate file differs from a .vstemplate file of a project.  It contains
      a ProjectCollection element.  This element exists out of 1 or more ProjectTemplateLink’s. 
      Nice to know is that a multi-project template can contain projects written in different
      languages.  It will be placed in one category of the New Project by using the
      ProjectType element.
   </p>
        <p>
      The creation of the project part is the same as a project template.  What I do
      is first creating for all the projects the templates.  Unzip them.  Then
      create your root .vstemplate file.  This file contains your metadata for the
      multi-project template.  Afterwards right click on the files, select send to
      and click Compressed (zipped) folder.  Place this zip file in your Visual Studio
      template folder.
   </p>
        <p>
      There’s one disadvantage when using multi-project templates. Individual projects cannot
      be assigned by the New Project dialog box.  Instead, the wizard will use the
      ProjectName attribute on the ProjectTemplateLink to specify the name of each project.
   </p>
        <p>
      You can solve this by using the Guidance And Automation Toolkit (GAT).  At this
      moment this tool isn’t officially released yet.  But you can download the CTP
      June 2006 <a href="http://msdn2.microsoft.com/en-us/teamsystem/aa718948.aspx">here</a>.
   </p>
        <p>
      I will blog later about this tool.  So stay tuned.<br /></p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=f36e18ce-db03-48bb-a1e7-71bb67e51efe" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Creating project templates in VS2005</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,f36e18ce-db03-48bb-a1e7-71bb67e51efe.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Creating+Project+Templates+In+VS2005.aspx</link>
      <pubDate>Mon, 08 Jan 2007 12:58:44 GMT</pubDate>
      <description>&lt;h3&gt;Introduction
&lt;/h3&gt;
&lt;p&gt;
   Why do you need them? We could give you a short answer about this.&amp;nbsp; When developing
   several projects in a company, you want them to have the same look.&amp;nbsp; So, just
   like me, for every new project you copy files, code, etc from a previous project.&amp;nbsp;
   The danger is that in the first place you forgot some items and then you have to add
   them later.
&lt;/p&gt;
&lt;p&gt;
   This all takes up a lot of work.&amp;nbsp; You could help yourself and your team by creating
   a project template.&amp;nbsp; When this template is installed you can use it, just like
   when you start to create a new project with one of the standard templates.
&lt;/p&gt;
&lt;h3&gt;VS2005 templates
&lt;/h3&gt;
&lt;p&gt;
   First, let’s take a look where all the templates can be found.&amp;nbsp; The standard
   templates can be found at this location: C:\Program Files\Microsoft Visual Studio
   8\Common7\IDE\ProjectTemplates\Web\CSharp\1033 for the CSharp web templates.
&lt;/p&gt;
&lt;p&gt;
   If you create your own templates they will be placed under: C:\Documents and Settings\&amp;lt;User&amp;gt;\My
   Documents\Visual Studio 2005\Templates.
&lt;/p&gt;
&lt;p&gt;
   You can change the location of this.&amp;nbsp; To do so follow the next steps:
&lt;/p&gt;
&lt;ol&gt;
   &lt;li&gt;
      Start VS2005 
   &lt;li&gt;
      Go to Tools/Options 
   &lt;li&gt;
      Expand Projects &amp;amp; Solutions 
   &lt;li&gt;
      Click on General 
   &lt;li&gt;
      Make your changes for Visual Studio user Project Templates location and Visual Studio
      user Item Templates location&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Difference between project and item templates
&lt;/h3&gt;
&lt;h4&gt;Item template
&lt;/h4&gt;
&lt;p&gt;
   An item template is an individual item that a user can add to a project by using the
   Add New Item dialog box.&amp;nbsp; 
&lt;/p&gt;
&lt;h4&gt;Project template
&lt;/h4&gt;
&lt;p&gt;
   Project templates contain complete projects and can be added by the user with the
   New Project dialog box.
&lt;/p&gt;
&lt;h3&gt;Inside a template
&lt;/h3&gt;
&lt;p&gt;
   With this you could put the templates somewhere on a network drive and everyone connects
   to this drive.&amp;nbsp; So you won’t have to deploy the templates to every developer.
&lt;/p&gt;
&lt;p&gt;
   When taking a closer look to the standard templates, you see that a template exists
   of a zip file containing all the files needed to create your project/item.&amp;nbsp; The
   most important file is the .vstemplate.&amp;nbsp; This file contains the definition how
   your project should look.&amp;nbsp; This file contains several blocks
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      TemplateData 
   &lt;li&gt;
      TemplateContent 
   &lt;li&gt;
      WizardExtension 
   &lt;li&gt;
      WizardData&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   At this moment I will only focus on the TemplateData and TemplateContent block.&amp;nbsp;
   So let’s take a closer look at them.
&lt;/p&gt;
&lt;h4&gt;TemplateDate
&lt;/h4&gt;
&lt;p&gt;
   This is the definition how the template is displayed in either New Project or Add
   New Item.&lt;br&gt;
   Several attributes can be set.&amp;nbsp; We list the most used.
&lt;/p&gt;
&lt;p&gt;
   Name: Specifies the name of the template&lt;br&gt;
   Description: The description of the template&lt;br&gt;
   Icon: The icon that will be displayed&lt;br&gt;
   ProjectType: the category under which it will be appearing.&amp;nbsp; A Category could
   be CSharp, VisualBasic,…
&lt;/p&gt;
&lt;p&gt;
   A full list can be found &lt;a href="http://msdn2.microsoft.com/en-us/library/hy7dh5te(VS.80).aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;h4&gt;TemplateContent
&lt;/h4&gt;
&lt;p&gt;
   This block specifies the contents of the template.&amp;nbsp; This block doesn’t have any
   attributes, but has a few child elements.&amp;nbsp; With the child elements you could
   define your projects, references, project collections and more.
&lt;/p&gt;
&lt;p&gt;
   Read the info &lt;a href="http://msdn2.microsoft.com/en-us/library/zfkkzb88(VS.80).aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;h3&gt;Create your template
&lt;/h3&gt;
&lt;p&gt;
   When you have created templates in VS2003, you know it took a long time to go. If
   you don’t know how this is done, read more info &lt;a href="http://msdn2.microsoft.com/en-us/library/zfkkzb88(VS.80).aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
   From VS2005 it only takes a few steps to create your template.&amp;nbsp; We will explain
   the first steps and then split up in the two types of templates.
&lt;/p&gt;
&lt;h4&gt;First steps
&lt;/h4&gt;
&lt;ul&gt;
   &lt;li&gt;
      Create a new project of the type you want to create your template. 
   &lt;li&gt;
      Change the project for your needs by adding your forms, classes, etc.&lt;br&gt;
      &amp;nbsp;&lt;img src="http://blog.svencipido.be/Blog/content/binary/solutionfortemplate1project.png" border=0&gt; 
   &lt;li&gt;
      Save the project 
   &lt;li&gt;
      Go to file/Export template 
   &lt;li&gt;
      A wizard pops up&lt;br&gt;
      &lt;img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard1.png" border=0&gt; 
   &lt;li&gt;
      Now choose your template style and if you have more than one project defined, the
      project you want to export.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Project template
&lt;/h4&gt;
&lt;p&gt;
   After choosing the project template you get the next step which leads you to this
   screen.&lt;br&gt;
   &lt;img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
   Fill in all project items as described above.&amp;nbsp; If you check the automatically
   import the template into Visual Studio, you don’t have to copy manually your template
   in the user template folder.
&lt;/p&gt;
&lt;p&gt;
   Press the finish button and your template will be generated.
&lt;/p&gt;
&lt;p&gt;
   If you check now the template file, you will see the zip file, containing your exported
   project.
&lt;/p&gt;
&lt;h4&gt;Item template
&lt;/h4&gt;
&lt;p&gt;
   If you choose for the item template, you will get the following screen as next step.&lt;br&gt;
   &lt;img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard3.png" border=0&gt;
   &lt;br&gt;
   Now check the item you want to export.&amp;nbsp; After pressing next you will get a new
   wizard screen.&lt;br&gt;
   &lt;img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard4.png" border=0&gt;
   &lt;br&gt;
   On this screen you can add the references, if needed by your selected item.&amp;nbsp;
   Press again next and you will get the item properties wizard screen.&lt;br&gt;
   &lt;img src="http://blog.svencipido.be/Blog/content/binary/exporttemplatewizard5.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
   Press finish to create your template.
&lt;/p&gt;
&lt;h4&gt;I don’t see the export template menu item
&lt;/h4&gt;
&lt;p&gt;
   It seems that sometimes the menu item isn’t visible.&amp;nbsp; If you follow the next
   steps the item will be available.
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      Right click on the toolbar 
   &lt;li&gt;
      Select Customize 
   &lt;li&gt;
      Click on the command tab 
   &lt;li&gt;
      Under Categories and select File 
   &lt;li&gt;
      Under commands select Export Template 
   &lt;li&gt;
      Drag this under File Menu&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Use your templates
&lt;/h3&gt;
&lt;p&gt;
   Now that we have our templates, we can use them.&amp;nbsp; Open Visual Studio and choose
   create new project.&amp;nbsp; You will get a screen like this
&lt;/p&gt;
&lt;p&gt;
   &lt;img src="http://blog.svencipido.be/Blog/content/binary/usetemplates1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
   On the right side you will see a section My Templates where you find your project
   template.&amp;nbsp; Choose the template, give it a name and press OK. The project will
   be created.
&lt;/p&gt;
&lt;p&gt;
   We also have created an item template.&amp;nbsp; Add a new item to your project.&amp;nbsp;
   You will see next screen.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
   -&lt;img src="http://blog.svencipido.be/Blog/content/binary/usetemplates2.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
   Also here you will find a section My Templates.&amp;nbsp; Choose your template, give it
   a name and press OK.&amp;nbsp; The item is created in your project.
&lt;/p&gt;
&lt;h3&gt;Customize your templates
&lt;/h3&gt;
&lt;p&gt;
   All templates support parameters so you could replace class names, namespaces,… on
   the moment the template is initiated.&amp;nbsp; These parameters are replaced by the wizard,
   the moment the user clicks OK on the New Project or Add New Item.
&lt;/p&gt;
&lt;p&gt;
   A list of all reserved parameters can be found &lt;a href="http://msdn2.microsoft.com/en-us/library/eehb4faa(vs.80).aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;h3&gt;Multi-project templates
&lt;/h3&gt;
&lt;p&gt;
   Multi project templates are in fact containers for 2 or more projects.&amp;nbsp; When
   choosing the template in the New Project dialog box, a solution with all included
   projects is created.
&lt;/p&gt;
&lt;p&gt;
   In common a multi-project template is almost built in the same way as a project template.&amp;nbsp;
   It exists out of
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      All projects 
   &lt;li&gt;
      Each project has its own .vstemplate file 
   &lt;li&gt;
      1 root .vstemplate file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   The root .vstemplate file differs from a .vstemplate file of a project.&amp;nbsp; It contains
   a ProjectCollection element.&amp;nbsp; This element exists out of 1 or more ProjectTemplateLink’s.&amp;nbsp;
   Nice to know is that a multi-project template can contain projects written in different
   languages.&amp;nbsp; It will be placed in one category of the New Project by using the
   ProjectType element.
&lt;/p&gt;
&lt;p&gt;
   The creation of the project part is the same as a project template.&amp;nbsp; What I do
   is first creating for all the projects the templates.&amp;nbsp; Unzip them.&amp;nbsp; Then
   create your root .vstemplate file.&amp;nbsp; This file contains your metadata for the
   multi-project template.&amp;nbsp; Afterwards right click on the files, select send to
   and click Compressed (zipped) folder.&amp;nbsp; Place this zip file in your Visual Studio
   template folder.
&lt;/p&gt;
&lt;p&gt;
   There’s one disadvantage when using multi-project templates. Individual projects cannot
   be assigned by the New Project dialog box.&amp;nbsp; Instead, the wizard will use the
   ProjectName attribute on the ProjectTemplateLink to specify the name of each project.
&lt;/p&gt;
&lt;p&gt;
   You can solve this by using the Guidance And Automation Toolkit (GAT).&amp;nbsp; At this
   moment this tool isn’t officially released yet.&amp;nbsp; But you can download the CTP
   June 2006 &lt;a href="http://msdn2.microsoft.com/en-us/teamsystem/aa718948.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
   I will blog later about this tool.&amp;nbsp; So stay tuned.&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=f36e18ce-db03-48bb-a1e7-71bb67e51efe" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,f36e18ce-db03-48bb-a1e7-71bb67e51efe.aspx</comments>
      <category>Architecture;.Net 2.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=fa2e080f-030b-48a8-bce4-925819b4ef52</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,fa2e080f-030b-48a8-bce4-925819b4ef52.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,fa2e080f-030b-48a8-bce4-925819b4ef52.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=fa2e080f-030b-48a8-bce4-925819b4ef52</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      When you want to build your solution in VS 2005, together with TFS as source control
      it could that you encountered the following error: 
   </p>
        <p>
      Build FAILED.<br />
      C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(2797,9): error
      MSB3491: Could not write lines to file "obj\project.vbproj.FileList.txt". Access to
      the path 'd:\builds\project\obj\project.vbproj.FileList.txt' is denied.
   </p>
        <p>
      The problem is that this file is checked into source control and they are marked as
      read-only.  Even by setting the read-only flag to off it doesn’t work, because
      the next build the flag is switched on again.  As they are intermediate files,
      generated by the build, these should never been checked in.  So to solve the
      error above, delete the file from SCC, delete the file from your HD and try again.
   </p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=fa2e080f-030b-48a8-bce4-925819b4ef52" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Team Build failed</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,fa2e080f-030b-48a8-bce4-925819b4ef52.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Team+Build+Failed.aspx</link>
      <pubDate>Wed, 03 Jan 2007 13:47:30 GMT</pubDate>
      <description>&lt;p&gt;
   When you want to build your solution in VS 2005, together with TFS as source control
   it could that you encountered the following error: 
&lt;/p&gt;
&lt;p&gt;
   Build FAILED.&lt;br&gt;
   C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(2797,9): error
   MSB3491: Could not write lines to file "obj\project.vbproj.FileList.txt". Access to
   the path 'd:\builds\project\obj\project.vbproj.FileList.txt' is denied.
&lt;/p&gt;
&lt;p&gt;
   The problem is that this file is checked into source control and they are marked as
   read-only.&amp;nbsp; Even by setting the read-only flag to off it doesn’t work, because
   the next build the flag is switched on again.&amp;nbsp; As they are intermediate files,
   generated by the build, these should never been checked in.&amp;nbsp; So to solve the
   error above, delete the file from SCC, delete the file from your HD and try again.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=fa2e080f-030b-48a8-bce4-925819b4ef52" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,fa2e080f-030b-48a8-bce4-925819b4ef52.aspx</comments>
      <category>.Net 2.0;TFS</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=49328c9e-45d5-4dc2-be61-081f13bf4f95</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,49328c9e-45d5-4dc2-be61-081f13bf4f95.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,49328c9e-45d5-4dc2-be61-081f13bf4f95.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=49328c9e-45d5-4dc2-be61-081f13bf4f95</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      As always, you want only a single instance running of your program.  To do this
      you have to make use of the Mutex object.  By using reflection we get the executing
      name of our application.  We will use it for checking if there’s already an instance.
   </p>
        <p>
      The Mutex object can be used for interprocess synchronization.  With this we
      could check if our application is already running.  With the waitone method we
      can request the  ownership of our mutext object.  If it return false, then
      there’s already a process running using this mutex object.
   </p>
        <p>
      Example code :
   </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System.Reflection;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System.Threading;<br /><br />
      …..<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span> Mutex
      s_Mutex;<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
      &lt;summary&gt;</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
      The main entry point for the application.</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
      &lt;/summary&gt;</span><br />
      [STAThread]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Main()<br />
      {<br />
      s_Mutex <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> Mutex(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>,
      Assembly.GetExecutingAssembly().GetName().Name);<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (s_Mutex.WaitOne(0, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>))<br />
      {<br />
      Application.EnableVisualStyles();<br />
      Application.SetCompatibleTextRenderingDefault(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>);<br />
      Application.Run(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> Form1());<br />
      }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span><br />
      MessageBox.Show(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Already
      an instance running"</span>, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"your
      application"</span>, MessageBoxButtons.OK, MessageBoxIcon.Warning);<br />
      }</span>
        </p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=49328c9e-45d5-4dc2-be61-081f13bf4f95" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Running a single instance of your .Net 2.0 Windows Application</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,49328c9e-45d5-4dc2-be61-081f13bf4f95.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Running+A+Single+Instance+Of+Your+Net+20+Windows+Application.aspx</link>
      <pubDate>Wed, 03 Jan 2007 08:41:28 GMT</pubDate>
      <description>&lt;p&gt;
   As always, you want only a single instance running of your program.&amp;nbsp; To do this
   you have to make use of the Mutex object.&amp;nbsp; By using reflection we get the executing
   name of our application.&amp;nbsp; We will use it for checking if there’s already an instance.
&lt;/p&gt;
&lt;p&gt;
   The Mutex object can be used for interprocess synchronization.&amp;nbsp; With this we
   could check if our application is already running.&amp;nbsp; With the waitone method we
   can request the&amp;nbsp; ownership of our mutext object.&amp;nbsp; If it return false, then
   there’s already a process running using this mutex object.
&lt;/p&gt;
&lt;p&gt;
   Example code :
&lt;/p&gt;
&lt;p&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Reflection;&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Threading;&lt;br&gt;
   &lt;br&gt;
   …..&lt;br&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; Mutex
   s_Mutex;&lt;br&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
   &amp;lt;summary&amp;gt;&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
   The main entry point for the application.&lt;/span&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
   &amp;lt;/summary&amp;gt;&lt;/span&gt;
   &lt;br&gt;
   [STAThread]&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Main()&lt;br&gt;
   {&lt;br&gt;
   s_Mutex &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Mutex(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/span&gt;,
   Assembly.GetExecutingAssembly().GetName().Name);&lt;br&gt;
   &lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (s_Mutex.WaitOne(0, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;))&lt;br&gt;
   {&lt;br&gt;
   Application.EnableVisualStyles();&lt;br&gt;
   Application.SetCompatibleTextRenderingDefault(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;);&lt;br&gt;
   Application.Run(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Form1());&lt;br&gt;
   }&lt;br&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt;
   &lt;br&gt;
   MessageBox.Show(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Already
   an instance running"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"your
   application"&lt;/span&gt;, MessageBoxButtons.OK, MessageBoxIcon.Warning);&lt;br&gt;
   }&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=49328c9e-45d5-4dc2-be61-081f13bf4f95" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,49328c9e-45d5-4dc2-be61-081f13bf4f95.aspx</comments>
      <category>.Net 2.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=59813782-be28-4be4-bc04-4d7059fb6f51</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,59813782-be28-4be4-bc04-4d7059fb6f51.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,59813782-be28-4be4-bc04-4d7059fb6f51.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=59813782-be28-4be4-bc04-4d7059fb6f51</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      The previous post was just about the basic principles of code snippets in VS2005. 
      Now we will describe the power boost of code snippets: the $name$ notation (or the
      literal replacement) and the object replacement.
   </p>
        <p>
      The literal replacement.
   </p>
        <p>
      When you want to create a code snippet with some customized parts (like variable type,
      variable name, ...) that must replaced by the developer after inserting the code snippet,
      you can use a literal.
   </p>
        <p>
      How do you create this?<br />
      In the Snippet element place an element called "Declarations".  In this element
      you place your literals which can be one or more literals.  The literal element
      has a few elements:
   </p>
        <ul>
          <li>
         ID: The ID of the literal 
      </li>
          <li>
         Default: The default value for the literal</li>
        </ul>
        <p>
      Optional you can add:
   </p>
        <ul>
          <li>
         Function: Function to execute when the literal receives focus in Visual Studio 
      </li>
          <li>
         Tool tip: short description of the literal</li>
        </ul>
        <p>
      Now you have created your literal, but you have to place it in your code snippet. 
      This is done by placing the $ sign in front and at the end of your Literal ID element. 
      Now go to the code element.  Within your code place the $literalID$ notation
      where you want it.  The next time you add the code snippet you will see a green
      rectangle.  This is the place where you have added your literal.  If you
      have inserted a default value this will be filled in the rectangle.
   </p>
        <p>
      You can have multiple insertions for the same $literalID$ element.  This gives
      us a nice effect in Visual Studio.  Only for the first entry you will see the
      green rectangle.  After filling in the rectangle, Visual Studio will automatically
      replace all the other literals with the same ID with your filled in value.
   </p>
        <p>
      Two examples:<br />
      Example 1: One literal
   </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;?xml
      version=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"1.0"</span> encoding=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"utf-8"</span>?&gt;<br />
      &lt;CodeSnippets xmlns=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"</span>&gt;<br />
      &lt;CodeSnippet Format=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"1.0.0"</span>&gt;<br />
      &lt;Header&gt;<br />
      &lt;Title&gt;My MessageboxSnippet&lt;/Title&gt;<br />
      &lt;Shortcut&gt;mmbs&lt;/Shortcut&gt;<br />
      &lt;Description&gt;My Snippet <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> messagebox <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> c#&lt;/Description&gt;<br />
      &lt;Author&gt;<br />
      &lt;/Author&gt;<br />
      &lt;/Header&gt;<br />
      &lt;Snippet&gt;<br />
      &lt;Declarations&gt;<br />
      &lt;Literal Editable=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"true"</span>&gt;<br />
      &lt;ID&gt;YourMessage&lt;/ID&gt;<br />
      &lt;ToolTip&gt;Place your message here&lt;/ToolTip&gt;<br />
      &lt;Default&gt;Place your message here&lt;/Default&gt;<br />
      &lt;Function&gt;<br />
      &lt;/Function&gt;<br />
      &lt;/Literal&gt;<br />
      &lt;/Declarations&gt;<br />
      &lt;Code Language=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"csharp"</span>&gt;&lt;![CDATA[MessageBox.Show(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"$YourMessage$"</span>);]]&gt;&lt;/Code&gt;<br />
      &lt;/Snippet&gt;<br />
      &lt;/CodeSnippet&gt;<br />
      &lt;/CodeSnippets&gt;</span>
        </p>
        <p>
      Example 2 : More literals and used more than one time
   </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;?xml
      version=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"1.0"</span> encoding=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"utf-8"</span>?&gt;<br />
      &lt;CodeSnippets xmlns=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"</span>&gt;<br />
      &lt;CodeSnippet Format=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"1.0.0"</span>&gt;<br />
      &lt;Header&gt;<br />
      &lt;Title&gt;My MessageboxSnippet&lt;/Title&gt;<br />
      &lt;Shortcut&gt;mmbs&lt;/Shortcut&gt;<br />
      &lt;Description&gt;My Snippet <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> messagebox <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> c#&lt;/Description&gt;<br />
      &lt;Author&gt;<br />
      &lt;/Author&gt;<br />
      &lt;/Header&gt;<br />
      &lt;Snippet&gt;<br />
      &lt;Declarations&gt;<br />
      &lt;Literal Editable=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"true"</span>&gt;<br />
      &lt;ID&gt;YourMessage&lt;/ID&gt;<br />
      &lt;ToolTip&gt;Place your message here&lt;/ToolTip&gt;<br />
      &lt;Default&gt;Place your message here&lt;/Default&gt;<br />
      &lt;Function&gt;<br />
      &lt;/Function&gt;<br />
      &lt;/Literal&gt;<br />
      &lt;Literal Editable=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"true"</span>&gt;<br />
      &lt;ID&gt;Title&lt;/ID&gt;<br />
      &lt;ToolTip&gt;Place your message title here&lt;/ToolTip&gt;<br />
      &lt;Default&gt;Place your message title here&lt;/Default&gt;<br />
      &lt;Function&gt;<br />
      &lt;/Function&gt;<br />
      &lt;/Literal&gt;<br />
      &lt;/Declarations&gt;<br />
      &lt;Code Language=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"csharp"</span>&gt;&lt;![CDATA[MessageBox.Show(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"$YourMessage$"</span>,<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"$Title$"</span>);<br />
      MessageBox.Show(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"$YourMessage$"</span>);]]&gt;&lt;/Code&gt;<br />
      &lt;/Snippet&gt;<br />
      &lt;/CodeSnippet&gt;<br />
      &lt;/CodeSnippets&gt;</span>
        </p>
        <p>
      As you can see, code snippets in VS2005 give some great power to developers. 
      I have created or downloaded and changed them to our needs, several good code snippets.
      Every developer has installed them locally.
   </p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=59813782-be28-4be4-bc04-4d7059fb6f51" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>Code snippets in VS2005 - Part 2</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,59813782-be28-4be4-bc04-4d7059fb6f51.aspx</guid>
      <link>http://blog.svencipido.be/Blog/Code+Snippets+In+VS2005++Part+2.aspx</link>
      <pubDate>Mon, 15 May 2006 17:08:07 GMT</pubDate>
      <description>&lt;p&gt;
   The previous post was just about the basic principles of code snippets in VS2005.&amp;nbsp;
   Now we will describe the power boost of code snippets: the $name$ notation (or the
   literal replacement) and the object replacement.
&lt;/p&gt;
&lt;p&gt;
   The literal replacement.
&lt;/p&gt;
&lt;p&gt;
   When you want to create a code snippet with some customized parts (like variable type,
   variable name, ...) that must replaced by the developer after inserting the code snippet,
   you can use a literal.
&lt;/p&gt;
&lt;p&gt;
   How do you create this?&lt;br&gt;
   In the Snippet element place an element called "Declarations".&amp;nbsp; In this element
   you place your literals which can be one or more literals.&amp;nbsp; The literal element
   has a few elements:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      ID: The ID of the literal 
   &lt;li&gt;
      Default: The default value for the literal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   Optional you can add:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      Function: Function to execute when the literal receives focus in Visual Studio 
   &lt;li&gt;
      Tool tip: short description of the literal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   Now you have created your literal, but you have to place it in your code snippet.&amp;nbsp;
   This is done by placing the $ sign in front and at the end of your Literal ID element.&amp;nbsp;
   Now go to the code element.&amp;nbsp; Within your code place the $literalID$ notation
   where you want it.&amp;nbsp; The next time you add the code snippet you will see a green
   rectangle.&amp;nbsp; This is the place where you have added your literal.&amp;nbsp; If you
   have inserted a default value this will be filled in the rectangle.
&lt;/p&gt;
&lt;p&gt;
   You can have multiple insertions for the same $literalID$ element.&amp;nbsp; This gives
   us a nice effect in Visual Studio.&amp;nbsp; Only for the first entry you will see the
   green rectangle.&amp;nbsp; After filling in the rectangle, Visual Studio will automatically
   replace all the other literals with the same ID with your filled in value.
&lt;/p&gt;
&lt;p&gt;
   Two examples:&lt;br&gt;
   Example 1: One literal
&lt;/p&gt;
&lt;p&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;?xml
   version=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"1.0"&lt;/span&gt; encoding=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"utf-8"&lt;/span&gt;?&amp;gt;&lt;br&gt;
   &amp;lt;CodeSnippets xmlns=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;CodeSnippet Format=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"1.0.0"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;Header&amp;gt;&lt;br&gt;
   &amp;lt;Title&amp;gt;My MessageboxSnippet&amp;lt;/Title&amp;gt;&lt;br&gt;
   &amp;lt;Shortcut&amp;gt;mmbs&amp;lt;/Shortcut&amp;gt;&lt;br&gt;
   &amp;lt;Description&amp;gt;My Snippet &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; messagebox &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; c#&amp;lt;/Description&amp;gt;&lt;br&gt;
   &amp;lt;Author&amp;gt;&lt;br&gt;
   &amp;lt;/Author&amp;gt;&lt;br&gt;
   &amp;lt;/Header&amp;gt;&lt;br&gt;
   &amp;lt;Snippet&amp;gt;&lt;br&gt;
   &amp;lt;Declarations&amp;gt;&lt;br&gt;
   &amp;lt;Literal Editable=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"true"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;ID&amp;gt;YourMessage&amp;lt;/ID&amp;gt;&lt;br&gt;
   &amp;lt;ToolTip&amp;gt;Place your message here&amp;lt;/ToolTip&amp;gt;&lt;br&gt;
   &amp;lt;Default&amp;gt;Place your message here&amp;lt;/Default&amp;gt;&lt;br&gt;
   &amp;lt;Function&amp;gt;&lt;br&gt;
   &amp;lt;/Function&amp;gt;&lt;br&gt;
   &amp;lt;/Literal&amp;gt;&lt;br&gt;
   &amp;lt;/Declarations&amp;gt;&lt;br&gt;
   &amp;lt;Code Language=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"csharp"&lt;/span&gt;&amp;gt;&amp;lt;![CDATA[MessageBox.Show(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"$YourMessage$"&lt;/span&gt;);]]&amp;gt;&amp;lt;/Code&amp;gt;&lt;br&gt;
   &amp;lt;/Snippet&amp;gt;&lt;br&gt;
   &amp;lt;/CodeSnippet&amp;gt;&lt;br&gt;
   &amp;lt;/CodeSnippets&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   Example 2 : More literals and used more than one time
&lt;/p&gt;
&lt;p&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;?xml
   version=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"1.0"&lt;/span&gt; encoding=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"utf-8"&lt;/span&gt;?&amp;gt;&lt;br&gt;
   &amp;lt;CodeSnippets xmlns=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;CodeSnippet Format=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"1.0.0"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;Header&amp;gt;&lt;br&gt;
   &amp;lt;Title&amp;gt;My MessageboxSnippet&amp;lt;/Title&amp;gt;&lt;br&gt;
   &amp;lt;Shortcut&amp;gt;mmbs&amp;lt;/Shortcut&amp;gt;&lt;br&gt;
   &amp;lt;Description&amp;gt;My Snippet &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; messagebox &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; c#&amp;lt;/Description&amp;gt;&lt;br&gt;
   &amp;lt;Author&amp;gt;&lt;br&gt;
   &amp;lt;/Author&amp;gt;&lt;br&gt;
   &amp;lt;/Header&amp;gt;&lt;br&gt;
   &amp;lt;Snippet&amp;gt;&lt;br&gt;
   &amp;lt;Declarations&amp;gt;&lt;br&gt;
   &amp;lt;Literal Editable=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"true"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;ID&amp;gt;YourMessage&amp;lt;/ID&amp;gt;&lt;br&gt;
   &amp;lt;ToolTip&amp;gt;Place your message here&amp;lt;/ToolTip&amp;gt;&lt;br&gt;
   &amp;lt;Default&amp;gt;Place your message here&amp;lt;/Default&amp;gt;&lt;br&gt;
   &amp;lt;Function&amp;gt;&lt;br&gt;
   &amp;lt;/Function&amp;gt;&lt;br&gt;
   &amp;lt;/Literal&amp;gt;&lt;br&gt;
   &amp;lt;Literal Editable=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"true"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;ID&amp;gt;Title&amp;lt;/ID&amp;gt;&lt;br&gt;
   &amp;lt;ToolTip&amp;gt;Place your message title here&amp;lt;/ToolTip&amp;gt;&lt;br&gt;
   &amp;lt;Default&amp;gt;Place your message title here&amp;lt;/Default&amp;gt;&lt;br&gt;
   &amp;lt;Function&amp;gt;&lt;br&gt;
   &amp;lt;/Function&amp;gt;&lt;br&gt;
   &amp;lt;/Literal&amp;gt;&lt;br&gt;
   &amp;lt;/Declarations&amp;gt;&lt;br&gt;
   &amp;lt;Code Language=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"csharp"&lt;/span&gt;&amp;gt;&amp;lt;![CDATA[MessageBox.Show(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"$YourMessage$"&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"$Title$"&lt;/span&gt;);&lt;br&gt;
   MessageBox.Show(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"$YourMessage$"&lt;/span&gt;);]]&amp;gt;&amp;lt;/Code&amp;gt;&lt;br&gt;
   &amp;lt;/Snippet&amp;gt;&lt;br&gt;
   &amp;lt;/CodeSnippet&amp;gt;&lt;br&gt;
   &amp;lt;/CodeSnippets&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   As you can see, code snippets in VS2005 give some great power to developers.&amp;nbsp;
   I have created or downloaded and changed them to our needs, several good code snippets.
   Every developer has installed them locally.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=59813782-be28-4be4-bc04-4d7059fb6f51" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,59813782-be28-4be4-bc04-4d7059fb6f51.aspx</comments>
      <category>.Net 2.0</category>
    </item>
    <item>
      <trackback:ping>http://blog.svencipido.be/Blog/Trackback.aspx?guid=76c111a0-08f8-45bb-8ed0-36da42987c70</trackback:ping>
      <pingback:server>http://blog.svencipido.be/Blog/pingback.aspx</pingback:server>
      <pingback:target>http://blog.svencipido.be/Blog/PermaLink,guid,76c111a0-08f8-45bb-8ed0-36da42987c70.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://blog.svencipido.be/Blog/CommentView,guid,76c111a0-08f8-45bb-8ed0-36da42987c70.aspx</wfw:comment>
      <wfw:commentRss>http://blog.svencipido.be/Blog/SyndicationService.asmx/GetEntryCommentsRss?guid=76c111a0-08f8-45bb-8ed0-36da42987c70</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
      Code snippets can make the life of a developer a lot easier.  Already in VS2003
      you had the possibility to add code snippets to your toolbox or make use of a third
      party tool.  In VS2005 Microsoft has added a code snippet manager.  We will
      explain in short how to create such a code snippet.
   </p>
        <p>
      The format of the code snippet is XML base.  An example of a code snippet file:
   </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;CodeSnippets<br />
      xmlns=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"</span>&gt;<br />
      &lt;CodeSnippet Format=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"1.0.0"</span>&gt;<br />
      &lt;Header&gt;<br />
           &lt;Title&gt;My MessageboxSnippet&lt;/Title&gt;<br />
           &lt;Description&gt;My Snippet <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> messagebox <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">in</span> c#&lt;/Description&gt;<br />
           &lt;Shortcut&gt;mmbs&lt;/Shortcut&gt;<br />
      &lt;/Header&gt;<br />
      &lt;Snippet&gt;<br />
      &lt;References&gt;<br />
      &lt;Reference&gt;<br />
      &lt;Assembly&gt;System.Windows.Forms.dll&lt;/Assembly&gt;<br />
      &lt;/Reference&gt;<br />
      &lt;/References&gt;<br />
      &lt;Code Language=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"VB"</span>&gt;<br />
      &lt;![CDATA[MessageBox.Show(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"My
      first own snippet"</span>)]]&gt;<br />
      &lt;/Code&gt;<br />
      &lt;/Snippet&gt;<br />
      &lt;/CodeSnippet&gt;<br />
      &lt;/CodeSnippets&gt;</span>
        </p>
        <p>
      We have several parts:
   </p>
        <ul>
          <li>
         Header 
         <ul><li>
               Title: Name of the snippet 
            </li><li>
               Description : Description of the snippet 
            </li><li>
               Shortcut : Shortcut to access the snippet</li></ul></li>
          <li>
         Snippet 
         <ul><li>
               Reference: references to DLL's needed when implementhing the snippet.  Be aware
               that this is only supported by VB.Net snippets.  Snippets for other code
               needs to add the reference manually in your solution. 
            </li><li>
               Code language: the language of the code 
               <ul><li>
                     VB 
                  </li><li>
                     CSharp</li></ul></li></ul></li>
        </ul>
        <p>
      The only thing left now is to save the snippet as a .snippet file and place it in
      the snippet directory.  By default your snippet directory can be found here :
      My Documents\Visual Studio 2005\Code Snippets\ and then the language and then the
      directory "My Code snippets".
   </p>
        <p>
      A complete course can be found in the <a href="http://msdn2.microsoft.com/en-us/library/ms165394.aspx">MSDN</a>.
   </p>
        <p>
      But there is an easier way.  The VS Editor Team has released a PowerToy named
      Snippy.  This is a very handy tool for creating your own snippets.  Click <a href="http://blogs.msdn.com/powertoys/archive/2005/10/04/477101.aspx">here</a> for
      more info.
   </p>
        <p>
      Some interesting code snippets:<br />
      Microsoft: <a href="http://msdn.microsoft.com/vstudio/downloads/codesnippets/default.aspx">http://msdn.microsoft.com/vstudio/downloads/codesnippets/default.aspx</a><br />
      NUnit: <a href="http://codebetter.com/blogs/scott.bellware/archive/2006/02/28/139446.aspx">http://codebetter.com/blogs/scott.bellware/archive/2006/02/28/139446.aspx</a><br />
      Public property: <a href="http://weblogs.asp.net/jeffwids/archive/2005/09/08/424679.aspx">http://weblogs.asp.net/jeffwids/archive/2005/09/08/424679.aspx</a></p>
        <p>
      I also found a great tool for world wide snippet sharing: <a href="http://www.codexchange.net/">http://www.codexchange.net/</a><br />
      And like gotdotnet there's also a gotcodesnippet site: <a href="http://gotcodesnippets.com/">http://gotcodesnippets.com/</a></p>
        <img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=76c111a0-08f8-45bb-8ed0-36da42987c70" />
        <br />
        <hr />
   My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</body>
      <title>How to create your own code snippets for VS2005?</title>
      <guid>http://blog.svencipido.be/Blog/PermaLink,guid,76c111a0-08f8-45bb-8ed0-36da42987c70.aspx</guid>
      <link>http://blog.svencipido.be/Blog/How+To+Create+Your+Own+Code+Snippets+For+VS2005.aspx</link>
      <pubDate>Thu, 11 May 2006 20:23:04 GMT</pubDate>
      <description>&lt;p&gt;
   Code snippets can make the life of a developer a lot easier.&amp;nbsp; Already in VS2003
   you had the possibility to add code snippets to your toolbox or make use of a third
   party tool.&amp;nbsp; In VS2005 Microsoft has added a code snippet manager.&amp;nbsp; We will
   explain in short how to create such a code snippet.
&lt;/p&gt;
&lt;p&gt;
   The format of the code snippet is XML base.&amp;nbsp; An example of a code snippet file:
&lt;/p&gt;
&lt;p&gt;
   &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;CodeSnippets&lt;br&gt;
   xmlns=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;CodeSnippet Format=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"1.0.0"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;Header&amp;gt;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Title&amp;gt;My MessageboxSnippet&amp;lt;/Title&amp;gt;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Description&amp;gt;My Snippet &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; messagebox &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;in&lt;/span&gt; c#&amp;lt;/Description&amp;gt;&lt;br&gt;
   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Shortcut&amp;gt;mmbs&amp;lt;/Shortcut&amp;gt;&lt;br&gt;
   &amp;lt;/Header&amp;gt;&lt;br&gt;
   &amp;lt;Snippet&amp;gt;&lt;br&gt;
   &amp;lt;References&amp;gt;&lt;br&gt;
   &amp;lt;Reference&amp;gt;&lt;br&gt;
   &amp;lt;Assembly&amp;gt;System.Windows.Forms.dll&amp;lt;/Assembly&amp;gt;&lt;br&gt;
   &amp;lt;/Reference&amp;gt;&lt;br&gt;
   &amp;lt;/References&amp;gt;&lt;br&gt;
   &amp;lt;Code Language=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"VB"&lt;/span&gt;&amp;gt;&lt;br&gt;
   &amp;lt;![CDATA[MessageBox.Show(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"My
   first own snippet"&lt;/span&gt;)]]&amp;gt;&lt;br&gt;
   &amp;lt;/Code&amp;gt;&lt;br&gt;
   &amp;lt;/Snippet&amp;gt;&lt;br&gt;
   &amp;lt;/CodeSnippet&amp;gt;&lt;br&gt;
   &amp;lt;/CodeSnippets&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
   We have several parts:
&lt;/p&gt;
&lt;ul&gt;
   &lt;li&gt;
      Header 
      &lt;ul&gt;
         &lt;li&gt;
            Title: Name of the snippet 
         &lt;li&gt;
            Description : Description of the snippet 
         &lt;li&gt;
            Shortcut : Shortcut to access the snippet&lt;/li&gt;
      &lt;/ul&gt;
   &lt;li&gt;
      Snippet 
      &lt;ul&gt;
         &lt;li&gt;
            Reference: references to DLL's needed when implementhing the snippet.&amp;nbsp; Be aware
            that this is only supported by VB.Net snippets.&amp;nbsp; Snippets for&amp;nbsp;other code
            needs to add the reference manually in your solution. 
         &lt;li&gt;
            Code language: the language of the code 
            &lt;ul&gt;
               &lt;li&gt;
                  VB 
               &lt;li&gt;
                  CSharp&lt;/li&gt;
            &lt;/ul&gt;
         &lt;/li&gt;
      &lt;/ul&gt;
   &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
   The only thing left now is to save the snippet as a .snippet file and place it in
   the snippet directory.&amp;nbsp; By default your snippet directory can be found here&amp;nbsp;:
   My Documents\Visual Studio 2005\Code Snippets\ and then the language and then the
   directory "My Code snippets".
&lt;/p&gt;
&lt;p&gt;
   A complete course can be found in the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms165394.aspx"&gt;MSDN&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
   But there is an easier way.&amp;nbsp; The VS Editor Team has released a PowerToy named
   Snippy.&amp;nbsp; This is a very handy tool for creating your own snippets.&amp;nbsp; Click &lt;a href="http://blogs.msdn.com/powertoys/archive/2005/10/04/477101.aspx"&gt;here&lt;/a&gt; for
   more info.
&lt;/p&gt;
&lt;p&gt;
   Some interesting code snippets:&lt;br&gt;
   Microsoft: &lt;a href="http://msdn.microsoft.com/vstudio/downloads/codesnippets/default.aspx"&gt;http://msdn.microsoft.com/vstudio/downloads/codesnippets/default.aspx&lt;/a&gt;
   &lt;br&gt;
   NUnit: &lt;a href="http://codebetter.com/blogs/scott.bellware/archive/2006/02/28/139446.aspx"&gt;http://codebetter.com/blogs/scott.bellware/archive/2006/02/28/139446.aspx&lt;/a&gt;
   &lt;br&gt;
   Public property: &lt;a href="http://weblogs.asp.net/jeffwids/archive/2005/09/08/424679.aspx"&gt;http://weblogs.asp.net/jeffwids/archive/2005/09/08/424679.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
   I also found a great tool for world wide snippet sharing: &lt;a href="http://www.codexchange.net/"&gt;http://www.codexchange.net/&lt;/a&gt;
   &lt;br&gt;
   And like gotdotnet there's also a gotcodesnippet site: &lt;a href="http://gotcodesnippets.com/"&gt;http://gotcodesnippets.com/&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.svencipido.be/Blog/aggbug.ashx?id=76c111a0-08f8-45bb-8ed0-36da42987c70" /&gt;
&lt;br /&gt;
&lt;hr /&gt;My thoughts, shares,... with .Net and Microsoft - The blog of Sven Cipido</description>
      <comments>http://blog.svencipido.be/Blog/CommentView,guid,76c111a0-08f8-45bb-8ed0-36da42987c70.aspx</comments>
      <category>.Net 2.0</category>
    </item>
  </channel>
</rss>