Andrej Tozon's blog

In the Attic


Silk Icons

This overly cool set of icons has just made it into my VS2005ImageLibrary folder. There are many icons in the set I've been searching for quite some time to include them in my application toolbars. I made several toolbar icons myself, but they are, well, not as good as the icons in this library. And released under a Creative Commons Attribution 2.5 License, the Silk icons are free to use.

[Found through Cool thing of the day]

Infragistics NetAdvantage for VS2005

Infragistics has just released the final version of their Windows/Web controls suite - NetAdvantage 2005 vol. 3 for Visual Studio 2005. After downloading and installing it, I fired up VS2005 and:

  1. Upgraded some of my projects... went smoothly.
  2. Checked the VS2005 Visual Inheritance Lockdown Feature status... it seems they too went with disabling the VI and so far I couldn't find any workaround to enable it. I wish they too will provide the means to re-enable Visual Inheritance in the next releases. [Update of an update] After reading Miha's post and spending a bit more time on this one, I decided that... I need to give it a few more rounds before making more comments on it. Looks like the issues I was having while playing with it probably weren't related to the lockdown feature, but my improper use of VI. However, the designer does behave a little unusual, depending on what you want to do with the controls' code. More to come.
  3. Used the ToolBox utility to get the contols' tool icons into my toolbox... if using this tool you get a weird error [Package 'ToolBox Control Installer Package' failed to load. at EnvDTE._DTE.ExecuteCommand(String CommandName, String CommandArgs)], check out this page for the possible resolution. It worked for me.

That said... this is another great release from Infragistics I've been waiting for since VS2005 RTMed - the final piece of my .NET 2.0 puzzle.

Windows Live Messenger starts kicking

Windows Live Messenger Beta has just been released to the closed Beta testers group. Quick-reading the partial feature list, among several, mostly cosmetic changes, one thing cought my eye - Sharing Folders. Being a fan of both MSN Messenger and FolderShare, this integration is right my alley.

"Sharing Folders” feature lets you create a shared folder with each of your Messenger contacts.  When either of you add/edit a file in your Shared Folder, we automatically share it between your computers the next time each of you sign in."

Some SQL2005 thoughts...

Working with the SQL Server 2005 in a past few months, I learned to like many of its new features and improvements, and some of them I'm posting here:

1. SQL2005 noise control - SQL Server 2000 and its implementation of Full Text Searching have been giving me a very hard time. First of, background index updating was slow, which meant you had to wait for a few seconds/minutes before the changed content popped up in the search results. The second thing was the dreaded "Execution of a full-text operation failed. A clause of the query contained only ignored words." error. You would get this error when your search query only included words from the "noise words list". There are some workaround solutions for this one, but none of them are pretty.
However, SQL2005 not only offers faster full-text-indexing [my experience so far is that any changed or added content appeared in the search result list immediately after the change - well, at least from the user experience point of view], but also has a very simple solution for taming the noise words error:

sp_configure 'transform noise words', 1

[from the Books Online: "When the transform noise words option is set to 1, SQL Server replaces noise words with the asterisk (*) in phrase queries."]

2. Common Table Expressions [CTE]: great, especially for working with self-referenced [recursive] queries

3. Error handling with transaction support or TRY...CATCH block with XACT_STATE function: if an error occurs in a TRY part of the TRY...CATCH block, the executing transaction is marked as uncommittable, which is one of the three states that XACT_STATE function can and will return:

  • -1 - the session has an uncommittable transaction
  • 0 - there is no active transactions
  • 1 - the session has an active transaction

Normally, you would check the transaction state with XACT_STATE in the CATCH part of the TRY...CATCH block to properly recover from an error:

  • if transaction state is -1 - can do nothing but rollback
  • if transaction state is 0 - nothing to do, really
  • if transaction state is 1 - there was an error, but the transaction is still committable; so... let's commit

Using TRY...CATCH for transaction control is a much more elegant and readable solution compared to doing this in SQL2000.

SQL Server 2005 holds many more secrets yet to be discovered. The time will show how useful they'll prove to be.

VS2005 Code Snippets

The basic idea behind Visual Studio 2005 Code snippets is to help developers write more code by actually typing less, while inserting templated code chunks or patterns, which we repeatedly use in our day-to-day coding.

Code snippets are easily accessible from your IDE. You can either type their (abbreviated) name and do some TAB tapping, or right-click in your code window and select:

  • Insert Snippet... [for insertion]
  • Surround With... [surrounds selected code with the snippet code]

If you prefer using keyboard shortcuts: use Ctrl+K, Ctrl+X for insertion and Ctrl+K, Ctrl+S for surround with.

Writing custom snippets is also easy; you'll find the recipe with all ingredients listed in the MSDN documentation. Try it, it's fun. As an example, I created a simple snippet, which creates the string.IsNullOrEmpty() test block:

Inserting snippet

Completing snippet insertion

You can download this snippet from here. Unzip the .snippet file and copy it to "My Documents\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets" folder. Enjoy.

[Also, feel free to peek around for other code snippets]

[Update: create code snippets faster with the Code Snippets Editor or Snippy /thanks, D.]