Archive for category Visual Studio

The Value of Being Free to See the Source

Since the source code to ASP.Net was made available, I’ve been using it extensively. Here’s a great example of why it’s so valuable.

I’ve been trying to integrate the Enterprise Library 3.1 Exception Handling Block into my application. My application is split into a core and web UI specific components, so I’ve defined errors in my code to be thrown when a resource is not available. The web application configuration file specifies that if a specific exception, e.g. a ResourceNotFoundException, is thrown, the Exception Handling Block should replace that exception with a 404 Resource Not Found error using Http. That should in turn use the CustomErrors feature to redirect to a 404 not found page.

Makes sense, and sounds simple, don’t you think?

Nothing in the docs says that it shouldn’t work.

But it doesn’t. It simply won’t work. Why? Well, there’s nothing on the web. But after spending some serious hours digging through the source code, I can finally see why.

Here’s a lovely little hidden-to-the-world snippet of the code I got inside of Visual Studio:

code = HttpException.GetHttpCodeForException(e);

// Don't raise event for 404.  See VSWhidbey 124147.
if (code != 404) {
  WebBaseEvent.RaiseRuntimeError(e, this);

So it would never work!

Nice of them to let me know.


1 Comment

Easy Data-loading with LINQ-to-SQL and LINQ-to-XML

.Net 3.5 had some nice tricks in it. LINQ-to-XML was one of them. With the new "X"-types, you can make working with XML really easy.

VB.Net 9 takes it one step further, and lets you write XML in your code without strings.

"Hey Rich, that’s old news," I hear you say. "And who’s interested in VB today anyway?"

Well, apparently there are a lot of VB-er’s still out there. I am mainly a C# developer myself, but I found that VB was perfect for a problem I had recently -  loading of XML data into a SQL Server table.

Read the rest of this entry »

, , , , ,


Remove and Sort Those Ugly “using-Statements”

Visual Studio 2008 has lots of goodies in it, like LINQ syntax, CSS editing, and testing tools. There’s a lesser-known feature which I really appreciate though – the “Remove and Sort Usings” command in the C# editor.

You activate the command by placing your cursor over the using statements and clicking on the right mouse-button.


Read the rest of this entry »

, , , ,


The LinqDataSource and the Hidden Viewstate

Yesterday I thought I’d learn about the LinqDataSource in ASP.Net 3.5, and got an interesting surprise.

The new LinqDataSource can also be used with a LINQ-to-SQL model to perform updates. You simply add the DataSource to your page, set the table name, and set EnableUpdate to true. Then, using a standard DataControl, you can make updates to your data entities.

The question is, how does this work? It appears to be a bit magical. Read the rest of this entry »

, , ,


Writing Custom Exception Classes the Quick Way

Until recently I thought this was a well-known feature. After demonstrating it a few times, I found out it wasn’t.

A long time ago, in an cubicle far, far away, someone created the .Net Framework. To cut a long story short, they simultaneously produced guidelines for creating Exception classes, which you should always use or face having your fingernails pulled out with a staple-gun.

The guidelines state:

“Use the common constructors shown in the following code example when creating exception classes. “


public class XxxException : ApplicationException
public XxxException() {… }
public XxxException(string message) {… }
public XxxException(string message, Exception inner) {… }
public XxxException(SerializationInfo info, StreamingContext context) {…}

Read the rest of this entry »

, , ,


.Net Source Code Now Available

Scott Guthrie has just announced that the source code for the .Net framework has just been made available for reference use.

It will be particularly useful to see how the controls in ASP.Net and Windows Forms have been done.

Detailed instructions for how to set it up are here.

One caveat: it’s not available for the Express editions of Visual Studio. Shame! I was just starting to have some fun with them too.

, , , ,

1 Comment

Efficient Software Development with Visual Studio Team System 2008

I was recently asked to do some research and give a presentation about using Visual Studio Team System 2008. I thought I’d experiment with and post it here.

[slideshare id 225505&doc=efficient-software-development-with-visual-studio-team-system-1200133974226602-2&w=400]

The presentation was for a large corporation, and will possibly not come across as being very useful for an online presentation. I have been working on it for a while though, and I think it’s worth publishing, if only as an introduction.

I’ve used competitive products to Team System for a long time, mainly open source:

  • SubVersion for source version control
  • CruiseControl.Net as a build server
  • NAnt for build scripts
  • MbUnit for testing
  • NCover for seeing my testing code coverage
  • VersionOne for project planning, task management, tracking and reporting
  • BugTracker for bug tracking
  • A Wiki for project documentation and guidelines

I wasn’t all-too impressed with the standard of Visual Studio Team Suite 2005, but I am a little bit happier with the 2008 version. It took a while to get it installed so that I could test it, and there were lots of seemingly undocumented points which hindered my progress, but once I’d got it up-and-running, I didn’t find it that bad. (I did have to install it on  virtual machine, and run it on my laptop.)

I think the best thing about Team System is that all the things I need to do are now integrated into one place. I didn’t have to go make changes to a dozen XML files in order to get a build server working. I didn’t have to install a Wiki for the project documentation. Using Team System would also avoid resistance to using the products, as I’ve faced before trying to get other team members to use such tools. Everything would just be there, out-of-the-box, and no one would argue about using them.

What I didn’t like about Team System are some of the subtle details which don’t work as they should do. I did a basic test of multiple check-outs, using the new features, but it didn’t work. The Unit Tests that I generated were confusing and were buggy.

The biggest problem though is the price. It’s darn expensive. I wouldn’t be able to afford Team System if I was just a small development shop. However, for a large corporation, it really could make sense.

I actually wonder if there’s room for a better competitor (Rational is possibly the only serious contender, and I find their software pretty naff). It actually wouldn’t to be too hard for some Python hackers somewhere. 🙂

1 Comment