Archive for March, 2010

Enabling WCF in IIS7

March 31, 2010 Leave a comment

If for some reason when you create your first WCF app and you get a HTTP 404 error, try running the following command

“%windir%\\framework\v3.0\windows communication foundation\servicemodelreg.exe” -i

this will install and setup iis for WCF ūüôā

Categories: ASP.NET

Globally overriding default datetime formatting

March 25, 2010 Leave a comment

Most people usually do not have access to the server’s locale settings. so if you need to programatically change the global default behaviour of datetime tostring or various locale properties, there is a simple way to do this.¬†

All you need is to add the following code to global.asax
void Application_BeginRequest(object sender, EventArgs e)
var customCulture = new System.Globalization.CultureInfo(“en-US”);
var DFI = System.Globalization.DateTimeFormatInfo.CurrentInfo.Clone() as System.Globalization.DateTimeFormatInfo;
DFI.DateSeparator = “/”;
DFI.ShortDatePattern = “dd/MM/yyyy”;
DFI.ShortTimePattern = DFI.LongTimePattern = “HH:mm:ss”;
customCulture.DateTimeFormat = DFI;
System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = customCulture;

Categories: ASP.NET

Visual Studio 2010 Certifications

March 16, 2010 2 comments

Visual Studio 2010

Do you want to see if you are ready to develop for the Windows Azure platform? Do you have what it takes to create Web applications by using Microsoft ASP.NET, JavaScript, Ajax, and Microsoft Silverlight? What about desktop applications that use Windows Presentation Foundation (WPF) technology? Perhaps you are the services developer using WCF or maybe you are skilled at accessing data with ADO.NET. Getting certified on Visual Studio 2010 helps show employers and potential clients that you have the skills you need to be successful.

With Microsoft Visual Studio 2010, you can create what you can imagine, build on the strengths of your team, and open up new possibilities. New prototyping, modeling, and visual design tools enable you to create innovative applications for Windows and the Web. And you can take advantage of new opportunities and capabilities offered by multi-core programming and cloud development tools.

Microsoft Certified Technology Specialist (MCTS)

MCTS certifications provide the foundation for Microsoft Certification. These certifications are designed to help validate your skills on the features and functionality of key technologies. You can show your depth of knowledge in one specific technology, earn multiple MCTS certifications to show breadth across different technologies, or build on the MCTS to earn one of our Microsoft Certified Professional Developer (MCPD) certifications.

Your Goal Certification Exam
To create Windows-based applications that run on corporate servers or user desktop computers. MCTS: .NET Framework 4, Windows Applications Exam 70-511: TS: Windows Applications Development with Microsoft .NET Framework 4
To create Web-based applications that run on the ASP.NET platform and are hosted on Internet Information Server. MCTS: .NET Framework 4, Web Applications Exam 70-515: TS: Web Applications Development with Microsoft .NET Framework 4
To create applications that communicate with servers or other applications in a connected or disconnected state. MCTS: .NET Framework 4, Service Communication Applications Exam 70-513: TS: Windows Communication Foundation Development with Microsoft .NET Framework 4
To create data-driven applications that access data from various sources, such as Microsoft SQL Server, Oracle, Microsoft Office Access, object data sources, XML, or other flat-file sources. MCTS: .NET Framework 4, Data Access Exam 70-516: TS: Accessing Data with Microsoft .NET Framework 4

Microsoft Certified Professional Developer (MCPD)

MCPD certifications help validate a comprehensive set of skills that are necessary to design, build, and deploy applications successfully by using Microsoft Visual Studio and the Microsoft .NET Framework. This certification builds on the MCTS certification and is designed to help provide hiring managers with a strong indicator of your potential job success. Candidates for the MCPD typically have two to three years of relevant experience and a commitment to remaining current in best practices and technologies.

Certification Certification prerequisites Exam requirements
MCPD: Windows Developer 4 MCTS: .NET Framework 4, Windows Applications

MCTS: .NET Framework 4, Service Communication Applications

MCTS: .NET Framework 4, Data Access

Exam 70-518: PRO: Designing and Developing Windows Applications Using Microsoft .NET Framework 4
MCPD: Web Developer 4 MCTS: .NET Framework 4, Web Applications

MCTS: .NET Framework 4, Service Communication ApplicationsMCTS: .NET Framework 4, Data Access

Exam 70-519: PRO: Designing and Developing Web Applications Using Microsoft .NET Framework 4

Upgrade from MCPD on Visual Studio 2008 to MCPD on Visual Studio 2010

If you currently hold an MCPD certification on Visual Studio 2008, you can take advantage of one or more of our streamlined upgrade paths to transition your skills and certifications to Visual Studio 2010.

Current certification Certification goals Exams
MCPD: Windows Developer 3.5 or MCPD: Enterprise Application Developer 3.5 MCPD: Windows Developer 4

MCTS: .NET Framework 4, Windows Applications

MCTS: .NET Framework 4, Service Communication Applications

MCTS: .NET Framework 4, Data Access

Exam 70-521: Upgrade: Transition Your MCPD Windows Developer 3.5, or Enterprise Application Developer 3.5, Skills to MCPD Windows Developer 4
MCPD: ASP.NET Developer 3.5 or MCPD Enterprise Application Developer 3.5 MCPD: ASP.NET Developer 4

MCTS: .NET Framework 4, Windows Applications

MCTS: .NET Framework 4, Service Communication Applications

MCTS: .NET Framework 4, Data Access

Exam 70-523: Upgrade: Transition Your MCPD ASP.NET Developer 3.5, or Enterprise Application Developer 3.5, Skills to MCPD Web Developer 4
Categories: Visual Studio

LINQ To SQL – Showing the executed queries that caused the error

March 4, 2010 Leave a comment

Ever feel irritated about LINQ to SQL not being able to show you what queries were executed? You never had this issue with normal sql because you were in control of the statement, but with LINQ to SQL you are no longer able to do that!

Fret not just implement the following class in your application, set your datacontext base class to this class (Globals.LoggedDataContext) instead of the default and you are good to go! From now onwards, when you encounter errors during submitchanges, you can see what exactly was executed and find out the problem!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Globals
public class ExecutedSqlTextWriter : System.IO.TextWriter
StringBuilder sb = new StringBuilder();
public string ExecutedQueries
get { return sb.ToString(); }
public void Clear() { sb = new StringBuilder(); }
void WriteToFile(string value)
public override void Write(char[] buffer, int index, int count)
WriteToFile(new String(buffer, index, count));

public override void Write(string value)

public override Encoding Encoding
get { return System.Text.Encoding.Default; }
public class LoggedDataContext : System.Data.Linq.DataContext
public LoggedDataContext(System.Data.IDbConnection connection) : base(connection) { CreateLogWriter(); }
public LoggedDataContext(string fileOrServerOrConnection) : base(fileOrServerOrConnection) { CreateLogWriter(); }
public LoggedDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mapping) : base(connection, mapping) { CreateLogWriter(); }
public LoggedDataContext(string fileOrServerOrConnection, System.Data.Linq.Mapping.MappingSource mapping) : base(fileOrServerOrConnection, mapping) { CreateLogWriter(); }

ExecutedSqlTextWriter theLog { get { return (ExecutedSqlTextWriter)this.Log; } }
void CreateLogWriter()
this.Log = new ExecutedSqlTextWriter();

public override void SubmitChanges(System.Data.Linq.ConflictMode failureMode)
catch (Exception ex)
string ExecutedSQL = theLog.ExecutedQueries;
throw new ApplicationException(ExecutedSQL, ex);

Categories: Uncategorized

IIS 6 and IIS 7, HTTP Error

March 2, 2010 Leave a comment

New in IIS6 and IIS7 is the HttpErr which stores all the http errors encountered by IIS before it reaches the app, e.g timeout, user disconnect etc. However in IIS 6 and IIS7 there is no GUI to edit this property. 

This is especially important in IIS7, since without knowing, your system drive may be having lesser and lesser space as more logs are stored

The following is an excerpt taken from msdn which gives you the reg key to update the http error folder so that you can move it somewhere else

Registry Path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters
Default Value: systemroot\system32\logfiles
Range: N/A
Specifies the location of the Httperr.log file. Httperr.log is a new feature in IIS 6.0. If HTTP.sys is unable to write an error to a Web site log because the request did not reach user mode, the error will be entered in Httperr.log. Errors that are written to Httperr.log include the following: 503 errors, idle connection time-outs, URL parsing errors, and the last 10 requests to a failed application pool.
Categories: IIS