I finally got the opportunity to use LINQ in a real project. Up until a couple of days ago it was always a quick prototype here, install the latest CTP there, read a blog about LINQ, etc. But there’s nothing like diving in and giving it your best shot on a data-intensive ETL app that would otherwise force you to hand-code a ton of opaque SQL strings using ADO.NET.
For the past two days, I have been sailing along and the code almost seems to be writing itself. Well not really, but I’m almost done with my app and I have not had to write a single SQL query, and not one INSERT or UPDATE statement.
It was especially nice to see that the SQL generated by LINQ for a moderately complex query was exactly what I expected. I was a bit concerned that the SQL would be convoluted and unnecessarily use temp tables, but after seeing what got generated I’m getting more confident that I won’t need to worry about it too much.
Perhaps the days of writing explicit SQL will become a thing of the past for me, much like writing assembler code was twenty years ago when I moved to a compiled language and no longer had to worry about the machine code behind the scenes.
Anyway, I hope to post more about LINQ as I continue to get better at it, but my initial test-drive has been extremely positive. Thank you Microsoft!
Categories: .NET · LINQ · Orcas · technology
The first thing I did after installing Visual Studio 2008 Beta 2 was to check out the new visual designer for WPF. My first impression was that it definitely worked better than the Cider add-in for Visual Studio 2005, but it was still missing something to give me a good visual design experience for my WPF app.
I heard mention of Microsoft Expression Blend after reading some blogs, and I even saw a demo at someone’s desk, but it looked like it was more targeted towards graphic artists than developers. In fact, Microsoft’s site even says this about it:
Design cutting-edge user interfaces and collaborate with developers to bring these stunning new types of applications to life.
Collaborate with developers? I am a developer, so this possibly couldn’t be what I needed! But one morning I came to work and figured I would give it a shot, and after using it for a couple of weeks now, I have found it to be a very useful tool!
First of all, it works reasonably well with a WPF project under Visual Studio 2005. You don’t need to convert your 2005 project to the new Visual Studio format (which was a plus for me because I’m not yet ready to do serious development under 2008 Beta 2).
The screen layout of Expression Blend is very nice, although it does get a bit crowded with the various panels and there is not much real estate provided for the “Artboard” that contains your WPF form. I solved this by increasing my secondary monitor to the highest resolution and now it’s pretty acceptable.
Speaking of two monitors, I have found it to be very productive to run Expression Blend on one monitor and Visual Studio on the other. This lets me work in Expression Blend for the visual design aspect of my app, and Visual Studio for the C# coding as well as the XAML. Expression Blend does let you edit the XAML for your form, but Visual Studio is a better editor for this. Once you save your app (in either tool), the other is smart enough to recognize the change and ask you if you wish to reload it.
One of the projects I am working on uses some customized styles to shape the application’s window (e.g. cornering off the edges using transparency). The new Visual Studio 2008 Beta 2 WPF designer did not show me these changes at design-time, but Expression Blend did! Visual Studio 2008 Beta 2 did read some of the styles (e.g. custom buttons), but Expression Blend seems to be more in touch with your customizations.
Anyway, I wanted to share my initial experience with these two tools and let you know that Expression Blend is not just for the graphic artist who knows nothing about programming! And as a graphically challenged developer, Expression Blend is bringing out a creative part of me I didn’t know I had!
Categories: .NET · Orcas · Visual Studio · WPF · technology
My app was in the final stages of testing last week, and we ran a home-grown load tester that simulated thousands of hits to a .NET 2.0 Windows service via a socket call (much higher than would ever take place). Everything worked fine, but memory usage in Task Manager for the service spiked at 110 mb and stayed there (normal memory usage was 20-25 mb). It made sense that it would go up temporarily since an in-memory Xml document was being built based on the packets sent during the load test. But it was surprising that it didn’t come back down at some point when the garbage collector kicked in.
I checked my app for any references that might be holding on to the Xml document, and everything looked ok. Then a colleague suggested that I take a look at the GC class in the System namespace, and I found the static method Collect which forces garbage collection to take place:
GC.Collect();
The next time I ran the load tester, memory spiked as expected but then came down after I forced garbage collection. I would assume this method has a cost associated with it, and your app could thrash if it’s executed too frequently (.NET probably leaves some memory padding to avoid subsequent thrashing), so finding a strategic place for it would make sense. In my case, it was after the Xml document was persisted to the file system and I no longer needed the in-memory document.
Anyway, I hope this helps anybody else who sees the Mem Usage column in Task Manager go up and not come down for their .NET apps.
Categories: .NET · technology
I have been using Visual Studio Team Systems & Team Foundation Server for source code control for a couple of projects this year. So far so good, but it wasn’t until last Friday that I really took a liking to it.
I needed to reorganize my team project’s folder structure (our trunk) and then branch off the trunk so we could have a copy for maintenance and continue on with our main development. Although I was a bit hesitant to start moving folders around on the server, TFS really did a good job at it. Definitely make a backup of your local workspace (i.e. your developer desktop) because TFS will move things around there too (based on your TFS workspace mapping), but overall TFS was pretty smart about things.
One manual step I had to do after changing the folder structure was to overlay the subfolders and files on my local machine that TFS did not know about that got left behind (e.g. some local projects and files that I did not check in). This was easy to do, and I’m glad TFS had the intelligence to leave the folder if it wasn’t empty after moving everything it did know about.
Branching was very easy as well. Just right-click on the server-side folder and select Branch from the context menu. I chose to branch from the latest version, but the other options like branching from a label or date are useful too.
Now for the really good part… I had to make a couple of small coding changes (bug fixes) on the trunk that also needed to get to the newly created branch. With my previous source control system, I would have checked the .cs files out in both places, made the changes in one set of files, and then copied and pasted to the other files, and then checked everything back in.
TFS provides a much better solution with its merge capability, and even let me merge based on a changeset so I didn’t have to specify all the files (it knew from the changeset).
Anyway, just thought I would share these TFS successes. It really is a big help for managing source control and team projects. My next step will be to build our projects on a dedicated build machine that gets everything from TFS (instead of doing builds locally).
Categories: .NET · TFS · VSTS · Visual Studio · technology
Microsoft has released Beta 2 of Visual Studio 2008 and .NET 3.5 (I guess the Orcas codename is getting phased out at this point). Here’s a good blog that talks more about it.
I’m downloading the Professional Edition now using the Microsoft Secure Content Downloader. It’s pretty big (3 gb), but fortunately I’ve been getting a decent download rate at work (2-3 Mbps).
Categories: .NET · Orcas · Visual Studio · technology
Here’s a plug for a book on .NET 3.0 Windows Workflow Foundation, written by a colleague of mine. It’s called Pro WF, by Bruce Bukovics, and is very well written. You can read my review on Amazon here.
Bruce discusses more about WF, and .NET in general, on his blog. Maybe he’ll reference my blog about his blog, and we’ll have a circular reference. I wonder if that will cause any problems with some search engines.
Categories: .NET · WF · blogging · technology
Looks like Orcas Beta 2 could be available either Thursday or Friday!
http://blogs.zdnet.com/microsoft/?p=594
This is great timing for me since I am just starting the next design and coding cycle of my product.
I’ve been looking forward to using LINQ for a while. It will be nice to move my SQL out of strings and into an environment where I get strong typing and Intellisense.
I’m also looking forward to the new WPF designer so I can see what my UI will look like at design time instead of runtime.
Hopefully things will go well with Beta 2, and I’ll post some blogs as I use it.
Categories: .NET · LINQ · Orcas · WPF · technology
Greetings from my blog on .NET! Several years ago, I wrote a couple of small applications in .NET 1.1, and last year wrote a prototype in .NET 2.0. But it wasn’t until January of 2007 that I started using .NET regularly at work. I have been using .NET 3.0’s WPF and WCF, and am planning on using WF soon.
I am far from an expert, and seem to be learning something new every day. I hope to share some useful concepts and ideas related to .NET and C# programming on this blog from time to time.

Categories: .NET