C#

Dec 17 2009

Checking assembly dependencies for .NET

Are you getting the dreaded "Could not load file or assembly" error in C#? Well there might be several causes of that, the most difficult to track down and fix is a missing assembly dependency.

Oct 09 2009

Generic XML Serialization Class

We had to add XML Serialization functionality to a bunch of different classes. Here is a nice generic class for adding static methods for Serialization and Deserialization to any of your classes...

Oct 07 2009

Re-throwing Exceptions in C# with InternalPreserveStackTrace

It is often the case that you need to re-throw an exception after handling it. The common problem with re-throwing exceptions is that you often lose stack trace information that can be extraordinarily useful for debugging purposes. I'll explain a technique that can be used to force the entire stack to be propagated when an exception is re-thrown.

Sep 23 2009

Solving xsd generation error: 'The element .... is missing'

In attempting to build source from an XML schema using the XSD command line tool, I kept getting an error about an element missing.

Aug 31 2009

DataAnnotations in ASP.NET MVC 1.0

DataAnnotations is the Microsoft way of declaratively adding validation rules to a model. You simply add an attribute to a property and voila, it has validation! The concept of DataAnnotations should be familiar to anyone who has worked in Ruby on Rails and added validation rules inside the ActiveRecord model. I'm going to go over some of my findings and walk you through using DataAnnotations. Hopefully my pain, will be your gain.

Aug 27 2009

Sorting Lists in C# with IComparable and IComparer

Collections can be sorted using a variety of techniques. I'm giong to go over a few of the techniques for implementing sorting with Arrays. This is meant as a reference.

Jul 28 2009

Default namespacing XSLT... a weird learning experience

Kenny and I ran into an interesting debacle yesterday while attempting to fix a bug. This debacle dealt with the use of XML namespaces and XSL transforms. Even though both of us are proficient with XSL, we still found ourselves in a 2 hour bug fix over what eventually turned out to be a simple namespacing problem.

The rule is... if an XML document has a default namespace it must be matched in XSL by prefixing.

Jul 20 2009

ASP.NET Redirection Module

In rebuilding the Ramsay Corporation website, we changed a large number of URLs for categories and products. To retain backwards compatibilities and provide the proper redirection for users and search spiders, I decided to create an HttpModule to check the Request URL for redirection.

Jul 01 2009

Iterating enum names and values in C#

Have you ever wanted to create a SELECT element with the names and values of an enum Type? I'll readily admit, in my earlier programming days I used to create the control manually.

Thanks to the C# System.Enum class in .NET and its static helper methods, I can enumerate the Names and Values in an enum Type, increasing maintainability of my application.

May 19 2009

Embedding an RSS feed with ASP.NET

RSS feeds are a great way to share data. We have a feed of product news that we wanted to embed in pages on our website. There are a variety of ways in which we could do this, but seeing how we like XSL and RSS is XML, it only seemed logical to use XSL to render feed links. This article focuses on loading the RSS feed on the server side and using XSL to transform the feed into HTML.

Recent comments