No return statement in the finally clause, please.

You cannot put return statement in the finally clause because Control cannot leave the body of a finally clause (Compiler error code CS0157)…Why? MSDN says that all statement in the finally clause must execute. MADN also states that

The purpose of a finally statement is to ensure that the necessary cleanup of objects, usually objects that are holding external resources, happens immediately, even if an exception is thrown.

Thus for releasing all locks and hold objects or in other words control cannot leave the finally block before finishing the cleanup task. However, an exception can be occurred in the finally block. And if it is not handled properly, code execution will stop and error is thrown.

Technorati Tags: ,,
Digg This

Scott Guthrie’s MVC Tutorial Links

ASP.NET MVC Framework
One of the things that many people have asked for over the years with ASP.NET is built-in support for developing web applications using a model-view-controller (MVC) based architecture. Last weekend at the Alt.NET conference in Austin I gave the first…

ASP.NET MVC Framework (Part 1)
Two weeks ago I blogged about a new MVC (Model View Controller) framework for ASP.NET that we are going to be supporting as an optional feature soon. It provides a structured model that enforces a clear separation of concerns within applications, and…

ASP.NET MVC Framework (Part 2): URL Routing
Last month I blogged the first in a series of posts I’m going to write that cover the new ASP.NET MVC Framework we are working on.  The first post in this series built a simple e-commerce product listing/browsing scenario.  It covered the high…

ASP.NET MVC Framework (Part 3): Passing ViewData from Controllers to Views
The last few weeks I have been working on a series of blog posts that cover the new ASP.NET MVC Framework we are working on.  The ASP.NET MVC Framework is an optional approach you can use to structure your ASP.NET web applications to have a clear…

ASP.NET MVC Framework (Part 4): Handling Form Edit and Post Scenarios
The last few weeks I have been working on a series of blog posts that cover the new ASP.NET MVC Framework we are working on.  The ASP.NET MVC Framework is an optional approach you can use to structure your ASP.NET web applications to have a clear…

ASP.NET MVC Preview 5 and Form Posting Scenarios
This past Thursday the ASP.NET MVC feature team published a new “Preview 5” release of the ASP.NET MVC framework.  You can download the new release here .  This “Preview 5” release works with both .NET 3.5 and the recently…

Technorati Tags: ,

kick it on

Project Rosetta programmers, are you ready for the Silverlight? Still wondering what Silverlight is?

Silverlight is the Microsoft’s answer to the Adobe’s Flesh. And considering the Microsoft’s marketing strategy and market share, I can bet this is going to be the next big thing in the Web 2.0 age.

So does that mean learning a new technology? The answer is – Yes. As an programmer you have to learn this Silver Light thing. Soon those static (including DHTML) websites will be history. This is the RIA age. RIA – Rich Internet Application – are getting more and more popular following Moory’s law.

But here is a good news from Microsoft. Microsoft has started a new project that will help one to learn this Silverlight stuff.  Below is the excerp from today’s MSDN Flash:

Project Rosetta
Still wondering what all the buzz around Silverlight is about? Check out Project Rosetta, a site dedicated to helping designers and developers build applications in Silverlight while taking advantage of skills they already know from their experience with Flash programming.

So if you know flash (or don’t. doesn’t matter), it is really easy to learn silverlight. But as with any other design skills, learning and being creative are two different things.

So get your hands started on Silverlight ASAP and get experienced before it’s too late.

Related Links: to c# converter

Many times we need to convert code to c#. There are many utilities to do this. but none of these is perfect as these have one or other shortcomings. Most of these utilities are the windows apps written in c# language. The draw back of windows app is that you need to upgrade the app at times.

I was looking for an online app for the conversion. And after some googling I found a cool online tool from the Developer Fusion Lab. This conversion tool is quite accurate in conversion and if it could not convert any code then it inserts the error message into the code. So one can easily identify the error message and do the manual conversion.

Convert VB.NET to C# – A free code conversion tool from Developer Fusion

True / False in classic VB

In classic VB (and classic ASP as well), zero is considered as false and any other non-zero integer is considered as true.

While debugging an asp page, I come across following line:

If Not Request.Form.Count Then

Now form count was 2 (true) so the condition should evaluate as false (Not true). But this was always evaluating as true. It took me half an hour to find the catch.

What actually happening here was that Not is a bit-wise operator in VB. It flips the bits. So,

2 is 0000 0010 in binary.
NOT 2 is 1111 1101 in binary.

Considering that the last bit is sign bit, this becomes -3.

Now our condition If NOT (2) becomes If (-3), which always evaluates to true (non-zero integers are always true in VB).

Technorati Tags: ,,,

Automatic Formatting of Markup (HTML) in ASP.NET

Daniel at dimebrain did a really fantastic work writing a plug-in for VS that can format the markup in When you build a web page using the VS designer, it auto generates the markup. But the auto generated code so clustered and impossibly hard to read.  You have to manually format the markup (HTML) code by hand. This is always very tiresome and boring job. Also this is wastage of time.

Daniel also felt the same. After being inspired by the Joe Stagner, he developed this plug-in. It provides an additional Edit menu item and hotkey (Ctrl+K, Ctrl+Z) to automatically line up attributes in a selection of text, or format the entire document if no text is selected. The meat of the add-in is a handful of regular expressions that parse tags (XAML, HTML, and ASP.NET directives) and a few IDE tools to line them up according to their indent level.

Download Links:

Screen Shots:

Top 20 Programming Books

1. Code Complete by Steve McConnell – Darn near a bible of software development goodness, Code Complete reminds us of our priorities. It’s essential and everyone who writes code should read this book.

2. The Pragmatic Programmer by  Andrew Hunt and Dave Thomas – I like to read this book at least every six months or so. It’s clean, clever, clear and full of concrete tips you can use to be a better, simpler, pragmatic programmer. A new classic.

3. Programming Pearls by Jon Bentley – This may feel initially like a C book, but it’s really an algorithms book at its heart. It’s old school with techniques and thought problems that can be applied today, even in language like Ruby and C#.

4. Refactoring: Improving the Design of Existing Codeby Fowler, Beck, Brant, Opdyke, Roberts Although the language used is Java, the concepts are universal. This is a very linear, easy to read, learn by example book. If you think you know how to refactor, but you haven’t read this book, pick it up and refresh yourself. You’ll find names for Refactorings you’ve used for years and you’ll definitely not only pick up new ones, but be better able to spot opportunities to use them.

5. Design of the UNIX Operating System by Maurice J. Bach So few programmers today can answer questions like “explain how virtual memory is managed” or “how are Unix processes different from Windows.” How did we get here. Know your history.

6. Design Patterns by Gamma, Helm, Johnson, Vlissides – One of the comments on Amazon says it best, “It is expected that any professional developer has read this book front-to-back. Buy it, read it, then put it in your bathroom and read it when convenient. Also, when you’re done, spend some time at the Portland Pattern Repository.

7. Working Effectively with Legacy Code by Michael Feathers – The book is highly entertaining and comes across as a conversation with a really sharp, really patient guru developer. Often, it’s a chore to slog through code-heavy books. But Feathers manages to keep my attention with interesting stories, loads of examples, and well-written text.

8 .The Cuckoo’s Egg by Cliff stoll – A sentimental favorite, The Cuckoo’s Egg seems to have inspired a whole category of books exploring the quest to capture computer criminals. Still, even several years after its initial publication and after much imitation, the book remains a good read with an engaging story line and a critical outlook, as Clifford Stoll becomes, almost unwillingly, a one-man security force trying to track down faceless criminals who’ve invaded the university computer lab he stewards. What first appears as a 75-cent accounting error in a computer log is eventually revealed to be a ring of industrial espionage, primarily thanks to Stoll’s persistence and intellectual tenacity. –This text refers to an out of print or unavailable edition of this title.

9. Head First Design Patterns by Elisabeth Freeman, Eric Freeman, Bert Bates, Kathy Sierra – I just started reading it yesterday and it is a really well written (lots of pictures and examples) and is put in terms even I understand. Even so early on I would recommend it to anyone wanting an introduction into design patterns.You may not want to include it is all the examples are in Java although if you know c# you should understand it and even the VB / C++ shouldn’t have to jump to far.

10. From Coder to Developer: Tools and Strategies for Delivering Your Software by Gunderloy and Sybex – started very interesting. For someone new to the business it gives a nice overview of what the whole software development process entails and made things a lot clearly for a new graduate like me.

11. Code Reading by Spinellis – is a good read for learning how to quickly and efficiently get to grips with an existing codebase. I’m fortunate enough to have worked on greenfield stuff my last couple of projects, but this is gold when starting at a new company and needing to get up to speed. Also great if you’re looking to join an open source project. (

12. Writing Secure Code 2 by Michael Howard – This book provides a great overview of what techniques are important when writing secure applications, and what pitfalls to avoid. The book does a good job at making a point through examples and by explaining possible exploits.

13. The Mythical Man Month by  Brooks – This is a touchstone book, where by merely mentioning the name, you instantly communicate a body of knowledge on software engineering insight. It’s full of truths about Software Engineering that are still relevant. 30 years later.

14. Patterns of Enterprise Application Architecture by Martin Fowler – Noted software engineering expert, Martin Fowler, turns his attention to enterprise application development. He helps professionals understand the complex–yet critical–aspects of architecture. Enables the reader to make proper choices when faced with a difficult design decision.

15. TCP/IP Illustrated Volume 1 by  W. Tichard Stevens – Even though this book was published in 1994, it still serves as a useful reference and learning tool for the TCP/IP protocol. There are of course changes and additions that have been made to TCP/IP over the last 7 years such as IPv6, but one can still refer to this book as a good source of information about the dynamics of TCP/IP. There are exercises at the end of each chapter, so it can, and has been used as an effective textbook.

16. Don’t Make Me Think: A Common Sense Approach to Web Usability, 2nd Edition by Steve Krug – A practical Web design usability guide, “Don’t Make Me Think!” is based on empirical observation not exhaustive statistics. Steve Krug’s five years of usability consulting and testing are distilled down to this thin yet gem-filled how-to. Krug observed how people actually use the Web rather than how we *think* they use it, gleaning key usability guidelines.

17. The Inmates are Running the Asylum: Why High Tech Products Drive Us Crazy and How to Restore the Sanity by Alan Cooper – It’s worth reading this book — even despite the painful tone he often takes — just to pick up on the ideas of creating concrete personas and how you use them to develop your product. We do that today at Microsoft (at least in Developer Tools), and it’s a highly successful way of not only building a good product, but also in helping hundreds of developers understand why a feature is ‘in’ or ‘out’, no matter how much they might like it personally.

18. Mastering Reguler Expressions by Jeffrey E. F. Friedl – Regular expressions, a powerful tool for manipulating text and data, are found in scripting languages, editors, programming environments, and specialized tools. In this book, author Jeffrey Friedl leads you through the steps of crafting a regular expression that gets the job done. He examines a variety of tools and uses them in an extensive array of examples, with a major focus on Perl.

19. Test Driven Development by Kent Beck – The book teaches the concepts of TDD by working through two complete sample projects. Along the way, Beck gives the reader valuable insight into the thought process and techniques behind successful test-driven development. When the reader has finished working through these sample projects, he should know enough about TDD to get started working on a TDD project.

20. Head Rush Ajax by Brett McLaughlin – The Head First Labs crew has done it again in this excellent into to Ajax. The book really gives a great overview of Ajax for both programmers and non-programmers alike. You don’t need to be a rocket scientist to pick this up. Although the book covers more PHP than I care for, and not enough of XML as I would like to see, it does an excellent job of covering their bases in a way that’s easy to understand. I highly recommend this book to anyone with little to no understanding of Ajax. Let’s pretty up the web, people!