Open XML – OLE Automation Date Issues
If you are exporting a date from C# to Excel using 2007, you probably will use the following: Math.Round(DateTime.Now.ToOADate(), 12).ToString() This exports the date as a OLE Automation date recognized by Excel 2007. How ever, in Excel 2010 this was causing issues, every time I exported to Excel 2010, it said that it has to [...]
Fixing the EF Tracing and Caching Provider Wrapper Issue
If you have been using the Tracing and Caching Provider Wrappers for the ADO.NET Entity Framework 4.0, you might of come across this error message when creating POCO objects, adding them to a Data Context and commiting them to the database using the Caching Wrapper: [NotImplementedException: The method or operation is not implemented.] EFCachingProvider.EFCachingDataReaderCacheWriter.GetName(Int32 ordinal) [...]
Random number of items from a Generic List extension method
Here is a code snippet for returning N number of items from a generic list using a extension method. This requires .NET 3.5. public static class Extensions { /// <summary> /// method for returning N number of random items from a generic list [...]
The custom tool ‘MSLinqToSQLGenerator’ failed. Unspecified error
I kept getting this error “The custom tool ‘MSLinqToSQLGenerator’ failed. Unspecified error. For me, this was caused when I was using partial classes and had several using statements at the top of the file: using System.Data.Linq; using System.Data.Linq.Mapping; using System.Data; using System.Collections.Generic; using System.Reflection; using System.Linq; using System.Linq.Expressions; using System.ComponentModel; using System; {namespace} {code} To [...]
Modify a Word 2007 Open XML document via C#
Interesting problem that I came across here…A client requested that their system was to have the ability to load in a Word 2007 Document, perform some text manipulation routines and save the document back to the server. Firstly, you can rename a docx document to docx.zip and you can extract all of the files in [...]
Best Coding Practices – TIP 3
The use of partial classes can help improve coding for the following reasons: As you can split code into seperate physical files, its easier to seperate UI and Business Logic that may belong in a single class Produces clean and organised code No performance hit… The compiler groups all partial classes into one entity during [...]
Using ContextMenuStrip and NotifyIcon classes with WPF
There are many ways to get a notification icon displaying in the system tray, this is how I managed to get it working using Windows Presentation Framework: public partial class ClassName : Window { private System.Windows.Forms.NotifyIcon m_notifyIcon; private System.Windows.Forms.ContextMenuStrip m_contextMenu; public ClassName() { InitializeComponent(); //Initalize the context menu strip m_contextMenu = new System.Windows.Forms.ContextMenuStrip(); System.Windows.Forms.ToolStripMenuItem mI1 [...]
Creating a generic list of anonymous types
Scenerio I have a simple HTML form on a ASP.NET Web page. This form is to post a number of values including several elements that are compulsory to perform several actions on the server. As we know, when we post values to ASP.NET these are available for Request.Form. All we know is the key and [...]
Using Nested Functions in C#
Scenario We currently have a templating API system where this allows developers to use a combination of C# and HTML markup to customized the display of the client’s websites. In this case, I needed a way to quickly perform some calculations and formatting without having to declare the function at design-time. My problem was I [...]


