Understanding and Using System.Transactions

These are some resources to help grasp System.Transactions functionality and use it effectively in your projects:

Features Provided by System.Transactions
http://msdn.microsoft.com/en-us/library/vstudio/ee818755(v=vs.100).aspx
Implementing an Implicit Transaction using Transaction Scope
http://msdn.microsoft.com/en-us/library/vstudio/ee818746(v=vs.100).aspx
MSDN Articles by John Papa
ADO.NET and System.Transactions
http://msdn.microsoft.com/en-us/magazine/cc163847.aspx
Revisiting System.Transactions
http://msdn.microsoft.com/en-us/magazine/cc163527.aspx
These are specific to TransactionScope (the way to go in most cases)
Here is a practical example of Using TransactionScope :
http://thewayofcode.wordpress.com/2011/12/11/handling-transactions-in-net-using-transactionscope/
This one gets in depth with the way a TransactionScope like functionality can be implemented. Gives you a good understanding of what is happening under the hood when using TransactionScope in some Repository implementations in multi-threaded scenarios.
http://msdn.microsoft.com/en-us/magazine/cc300805.aspx
Here is another example of implementing a transactional repository :
http://www.codeproject.com/Articles/31270/A-Transactional-Repository-Implementation-in-NET
There are excellent tips here about configuring TransactionScope when used with SQL Server:
http://blogs.msdn.com/b/dbrowne/archive/2010/06/03/using-new-transactionscope-considered-harmful.aspx
This is a good resource for CommitableTransaction usage – http://www.codeproject.com/Articles/55472/Committable-Transactions-in-C-SQL
And this one has brilliant under-the-hood coverage – http://www.codeproject.com/Articles/35087/Truly-Understanding-NET-Transactions-and-WCF-Impl

Job Opening – Windows GUI Developer

We have a 3-4 month contract position open for a Windows GUI Developer in our group at Calabasas, California:

  • 2+ years experience developing C++/C# Windows thick-client applications
  • Expert in GUI development on Windows
  • Expert in Object Oriented Analysis and Design (OOA/OOD)
  • Deep understanding of client-server software development
  • Experience in multithreading, and thread synchronization
  • Excellent communication skills (written and verbal)
  • Highly organized and detail oriented
  • BSCS/BSEE or equivalent

If you are interested, contact me. The position is available now.

Dial Gauge is a ProgressBar

I am not just being philosophical here. In WPF, ControlTemplates allow you to transform a control’s appearance. This is not the same as applying stylesheets. This is an entirely new level of customization. What you see in the screenshot below looks like a Dial but is actually a simple ProgressBar control wearing a “Dial” template. The Dial template was created using Microsoft Expression Blend .

dial-is-a-progressbar.PNG

Include the ControlTemplate as a Window.Resource and then assign it to ProgressBar element’s Template attribute :

         

Of course that is not all. The ControlTemplate must define some named elements of FrameworkElement type. Charles Petzold has explained it in detail : MSDN Magazine Article. So, I will not repeat it here.

The sample code can be downloaded here : DialTest.zip
License : Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

WPF – LINQ to SQL Sample

This exercise in binding a WPF ListView control with LINQ to SQL was a lot of fun ! The following image shows data from AdventureWorks sample database displayed in the ListView control. The end result is very admirable, even in this very basic demo. Feeling a complete sense of freedom is unavoidable when working with WPF.

Linq2SqlSample1.Png

This sample demonstrates :

  1. LINQ to SQL mapping.
  2. WPF ListView Control DataBinding.
  3. Displaying images stored in database as varbinary in WPF control.

The sample code can be downloaded here : WPF-LINQ to SQL Sample
License : Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

Creative Commons License

Customize log4net Output Path

The default log4net output path is relative to the startup directory of your executable. To customize the output path, you can override the base Appender’s File property in your own Appender class. The following example describes how to route the log files relative to the temp folder :

   public class MyOwnAppender : log4net.Appender.RollingFileAppender
   {
         public override string File
         {
             get
             {
                 return base.File;
             }

            set
            {
                if (Path.IsPathRooted(value))
                {
                    base.File = value;
                }
                else
                {
                    base.File = Path.Combine(Path.GetTempPath(), value);
                }
            }
        }
    }

Your log4net config file must be modified so that log4net can locate and use your custom Appender. If MyOwnAppender is in MyNamespace and you have implemented it in MyLoggerLib.dll :