Blog Home 
public interface IGrocholski - .NET Development

RSS 2.0 Atom 1.0 CDF  
 
Sign In
 
 Wednesday, June 06, 2007

Lately I've been into all things "Orcas" (i.e. LINQ, Acropolis, Astoria, Jasper, etc.) However, the one thing I haven't really delved into yet is WPF. Since it's getting all the buzz, I decided to dig in and see what it's about. Admittedly I haven't gotten all that far yet, I'm still looking at how the WPF application model differs from that of Win32, but I have been amazed at how easy it is do some things, particularly when it comes to 3D and animation. For example within 20 minutes approximately 50 lines of xaml I was able to take a label, project it into a 3D cube, and then rotate the cube on its vertical axis. The result is something that looks like this:

Of course, when the app runs it actually spins. To me, that's pretty mindblowing.

The source code is attached if you want to take a look at how simple this is. (Note: HelloWPF.sln was written with Visual Studio "Orcas", I'm not entirely sure if it will work on Visual Studio 2005 with the WPF extension installed).

ag

HelloWPF.zip (41.32 KB)
6/6/2007 5:56:04 AM (Central Standard Time, UTC-06:00)  #    Comments [1]   .NET Development | Orcas | WPF  |  Trackback
 Tuesday, June 05, 2007

Over the past month or so Microsoft has released a number of CTP's targeted at Visual Studio "Orcas". You should already know about Silverlight (if you don't then you probably shouldn't continue reading this post). Of course Silverlight gets the spotlight, and it should, because it looks so cool (check out the Netflix demo to see what I'm talking about). With everyone ranting and raving about Silverlight, some middle tier projects have been released under the radar (detail below.. As you know this kind of stuff doesn't get all the hype that UI innovations do, but they're not trivial projects. I recommend checking them out when you have some time.

Acropolis

“Acropolis” builds on the rich capabilities of Microsoft Windows and the .NET Framework, including Windows Presentation Foundation (WPF), by providing tools and pre-built components that help developers quickly assemble applications from loosely-coupled parts and services.

Astoria

The Microsoft Codename "Astoria" project is an incubation effort at Microsoft focused on exploring how various emerging world-wide-web technologies and concepts can be combined with the Microsoft Data Platform to provide a first-class infrastructure for building the next wave of internet applications.

The goal of Microsoft Codename Astoria is to enable applications to expose data as a data service that can be consumed by web clients within corporate networks and across the internet. The data service is reachable over regular HTTP requests, and standard HTTP verbs such as GET, POST, PUT and DELETE are used to perform operations against the service. The payload format for the data exchanged with the service can be controlled by the client and all options are simple, open formats such as plan XML and JSON. The use of web-friendly technologies make it ideal as a data back-end for AJAX-style applications, Rich Interactive Applications and other applications that need to operate against data that is across the web.

The first Astoria CTP is a dual release, making Astoria available in the form of downloadable bits that can be used to build data services that are entirely contained within a single computer or network and as an experimental online service that you can use to create online stores that are hosted by Microsoft and are accessible over the internet.

Jasper

Jasper leverages the power of dynamic languages and the concept of convention over configuration to provide a programming surface for data that enables rapid development of data-bound applications. While most other rapid data access frameworks are only capable of working against simple databases, Jasper can scale to almost any database, regardless of size or complexity. This is possible because Jasper takes advantage of the ADO.NET Entity Framework’s significant investments in mapping and conceptual data modeling.

ag

6/5/2007 6:36:54 AM (Central Standard Time, UTC-06:00)  #    Comments [1]   .NET Development | Orcas  |  Trackback
 Thursday, May 31, 2007

Forgive me dear readers. I know I've been a little lax on the whole blog thing recently. This has been due to the fact that I've been diving deep into Visual Studio "Orcas" and LINQ in preparation for the May 2007 DevCares. My slide decks and demos should be attached to this post (if I remember to click the attach button).

This is some really cool technology that will make you rethink the way you access and query data. I recommend checking it out before "Orcas" ships (some time this Fall).

You can download the Orcas beta here.

If you're an MSDN subscriber you can download an ISO image from your subscription page.

If you want more info on LINQ I recommend checking out Scott Guthrie's blog. He has been posting a number of entires on LINQ over the past couple of months.

For some really good content head on over check out the session from MIX '07. All session are downloaded for your viewing pleasure (on iPod or Zune).

In particular I would recommend Anders Hejlsberg's presentation on LINQ. This is the guy that came up with the idea. No one should be this smart.

(A note on the demos. These demos were created running Visual Studio "Orcas" Beta 1. I installed this on my host Vista machine side by side with Visual Studio 2005. Usually I'd Virtual PC this kind of thing, but I'm also highly impatient and like a quicker response. I haven't had any problem to date, but I do know that if you uninstall the Beta you'll need to fix your VS 2005 installation by running the install media again.)

ag

LINQ.zip (2.03 MB)
5/31/2007 7:39:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0]   .NET Development | Orcas  |  Trackback
 Monday, February 26, 2007

Lately I've been rereading Steve McConnell's classic "Code Complete". A great book and I recommend it for all. Coincidentally he was also on .NET Rocks this past week discussing his books. He gave a quote by Stan-Kelly Bootle that I think is great and worth repeating:

your program n. A maze of non sequiturs littered with clever-clever tricks and irrelevant comments. Compare MY PROGRAM.

my program n. A gem of algoristic precision, offering the most sublime balance between compact, efficient coding on the one hand and fully commented legibility for posterity on the other. Compare YOUR PROGRAM.

So the next time you're writing some code, try keeping this in mind and see what happens.

ag

2/26/2007 9:42:09 AM (Central Standard Time, UTC-06:00)  #    Comments [0]   .NET Development  |  Trackback
 Friday, February 23, 2007

Service Pack 2 for all editions of SQL Server 2005 was released on Monday. Unfortunately for us .NET developers, the Visual Studio Bootstrapper we were hoping would ship with the release did not. Mike on the SQL Server Express team is working on it and hopes to release it by mid March. You can read more on his work here.

I'm not a patient guy so I decided to create my own. (After all, shouldn't I, since I've been raving about the bootstrapper as of late?)

Here's what it does:
1. Check if SQL Express is installed
2. If SQL Express is not installed, it install SQL Express SP2
3. If SQL Express RTM is installed, it upgrades RTM to SP2
4. If SQL Express SP1 is installed, it upgrades SP1 to SP2
5. If SP2 or later is installed, it does nothing

These checks are performed by my SqlExpressSP2 application. All these does is read the CurrentVersion value of the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SQLEXPRESS\MSSQLServer\CurrentVersion registry key.

I tested the boostrapper on installs on Windows XP SP2 and Windows Vista business. The installs worked without problem. I created an installer for the bootstrapper, but it's file size was over 55Mb, a little to big to dump on the blog. So, if you want a the bootstrapper you'll need to create it yourself via the following steps:

1. Create the following directory: [drive]:\[program files]\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\SqlExpressSP2.

2. Copy these files to the folder created in step 1 above:
     2.1. product.xml (.55 KB)

     2.2. SqlExpressSP2Chk.exe (16 KB)

3. Download SQL Server 2005 Express Edition Service Pack 2 from the download page

4. Create the following directory Create the following directory: [drive]:\[program files]\Microsoft Visual Studio 8

\SDK\v2.0\BootStrapper\Packages\SqlExpressSP2\en.

5. Copy the following files to the the direction created in step 4 above:
     5.1. SQLEXPR32.EXE (downloaded in step 3 above)

     5.2. package.xml (9.61 KB)

     5.3. eula.txt (8.03 KB)

To use the bootstrapper follow the steps:

1. Fire up Visual Studio 2005.

2. Create a Setup and Deployment project.

3. Go to the Projects menu and click Properties.

4. Click the Prerequisities button.

5. You should see an entry in the prerequisites list for SQL Server Express Edition SP2.

6. Select the prerequisite(s) you want and select the "Download prerequisites from the same locations as my application" option.

7. Click OK.

8. Click Apply and OK.

9. Build you Setup and Deployment project.

10. SQL Server Express 2005 SP2 will now be deployed with your application.

Hope this helps.

ag

2/23/2007 7:19:01 AM (Central Standard Time, UTC-06:00)  #    Comments [3]   .NET Development | Tools  |  Trackback
 Tuesday, February 13, 2007

In order to verify the integrity of a package file the Visual Studio Bootstrapper keeps track of either a Hash or PublicKey value.  These are indicated by attributes in the Bootstrapper package manifest. However, what if you don't know the Hash or PublicKey value? I ran into this situation recently when creating a Bootstrapper for a third part application I needed to include with my application. To resolve the issue I created a couple of utilities that will determine the Hash and PublicKey of a given file (if signed). I then put these values into the bootstrapper's package.xml file and everything worked as expected.

Here's the file containing the utilities: blogs.rba.agrocholski.20070213.001.file.001.zip (75.71 KB)

ag

2/13/2007 12:17:15 PM (Central Standard Time, UTC-06:00)  #    Comments [0]   .NET Development | Tools  |  Trackback
 Thursday, February 08, 2007

One of my favorite features in Visual Studio 2005 is the new Bootstrapper functionality. You can get an overview of it here. In short, it replaces the merge modules of old. It allows you to make your application a prerequisite that you can then bundle with other applications.

When you dig into it, you'll see that it's essentially based on a couple of xml configuration files (package.xml and product xml). These configuration files allow you to specify which files to include in te bootstrapper, any prerequisites required by your application, and and any install checks (i.e. registry key evaluation) that needs to be performed during install.

Managing these config files isn't the easy of things as their schemas aren't well documented. However, David Guyer has created a tool that can help you modify and created these xml files. You can get the tool here. One word about the tool, I've usually had to tweak the files generated by this tool to get everything to work properly.

So, you may be asking yourself "Why would I really want to use this?" Well, I can name two instances off hand were it's come in handy for me.

1. I needed to install a named instance of Sql Server Express with network connectivity enabled. To do this, I tweaked the package.xml and product.xml files for the SQL Server 2005 Express Edition bootstrapper that comes with Visual Studio.

2. I needed to install Sql Server Express SP1. This required the creation of a custom bootstrapper from scratch. This wasn't to hard but I also had to create an application that would determine if Sql Server Express was installed, and if it was install which version. If Sql Server Express was not installed or Sql Server Express RTM was installed SP1 would then be installed. If not, the installation is bypassed.

There are a number of other uses for this unheralded feature. Take a look at it when you have the time.

ag

2/8/2007 9:53:44 PM (Central Standard Time, UTC-06:00)  #    Comments [0]   .NET Development | Tools  |  Trackback
 Wednesday, January 31, 2007

A while back Mike posted a link to all the various keyboard shortcuts in visual studio. Rob Caron recently posted some nice artwork that includes some of the shortcuts. While it doesn't have everything, it can come in pretty handy (ok - bad pun).

ag

1/31/2007 8:00:36 AM (Central Standard Time, UTC-06:00)  #    Comments [0]   .NET Development  |  Trackback
 Thursday, January 25, 2007

We agree, I hope, that test driven development is one of the founding pillars of solid software construction. However, have you ever been on a project that contained so many dependencies that you found yourself writing more configuration and tear down code than actual unit tests?

For example, a typical scenario these days has a database, a web app, some web service, and a windows app. The web app updates the database and the client app calls the web service to pull down data. However, how do you adequately test the client code that calls the web service. Do you write a bunch configuration code to have the web app insert data? But what if the data already exists? You'll need to write more configuration code to clean out the database. Ok, maybe you could write a couple of lines to drop the database and attach an .mdf file. Or...

Wait a minute, is this really unit testing? No, it's integration testing. All you want to do is test the client code that calls the web service. You don't care what the web service does. Enter mock objects. By using mock objects you can eliminate the dependencies by mocking them. Essentially what you do is interecept calls to the real objects and substitute mock objects in their place. This gives you the power to control what gets returned from your calls and allows  you to actually test your objects without having to worry about dependencies.

I've used a number of mock objects over the past year or so, including EasyMock.NET, Rhino Mocks , TypeMock, and  NMock. Of these NMock has been my favorite. Unlike the mock object frameworks in order to mock an object with NMock you must define an interface that the object implements. A little more work, but this a good practice anyway. Best of all NMock is free.

So, if you want to make implementing test driven development easier try mocking something (just not me).

ag

1/25/2007 4:08:36 PM (Central Standard Time, UTC-06:00)  #    Comments [0]   .NET Development | Tools  |  Trackback
 Monday, January 22, 2007

I originally encountered this issue with a client in 2006.

If you use the Close and Dispose methods of a Connection object in ADO.NET is the connection immediately returned to the pool? You might think so, but not really.

After doing some research I found out that closing the connection .NET doesn't actually close it. Once a connection is closed in .NET, the connection is marked as dead but remains open. The CLR then cleans up, finally closes, these connections every 4-8 minutes. All connections will close if the app domain that launched the app shuts down. Per Microsoft, this is by design.

I tested this out to verify by running a test app that executes a SqlDataReader. After the SqlDataReader is executed and the Close method is called I ran sp_who. Sure enough the connection was still open. I continued to run sp_who every 30 seconds. After 6 minutes, the connection finally closed.

What to do, what to do. After doing a little more digging I found a method new to .NET 2.0. Enter SqlConnection.ClearPool(SqlConnection connection). By calling this method all inactive connections in the pool are cleaned up (closed) immediately.

Not trusting MSFT I decided to try this out. I modified my test app to have a max pool size of 10, launch 10 threads with each thread executing a SqlDataReader 1000 times. The first time I ran it without calling ClearPool. I then monitored the connections via sp_who. Sure enough 10 connections showed up. After the SqlDateaders finished executing the connections remained opened for 7 minutes.

I then ran the app again utilizing the ClearPool method after each SqlDateader finished executing. This time as when I executed sp_who I saw the number of connections increase and decrease depending on the number of active SqlDataReaders. Once all readers were done executing no connections remained open.

What does all this mean? I'm not quite sure, but I will say that it is important to consider how you handle your connections with .NET, especially in a high transactional environment.

As an addendum, when running on Vista this issue never occurs. It looks MSFT has updated garbage collection to prevent this from happening.

ag

1/22/2007 8:35:55 AM (Central Standard Time, UTC-06:00)  #    Comments [0]   .NET Development | Exceptional  |  Trackback
 Friday, January 19, 2007

This is an homage to James Avery, the man always looking for new tools.

We all have those little tools that we use when writing code to help our productivity. I was looking around on one of my external hard drives last night and realized that I have a ton of tool installers sitting there. As I looked through them I realized I'm currently only using a handful. So rather than going into detail on all the various tools I have lying around, I thought I'd give the lowdown on the ones I'm currently using. So here you go:


SlickEdit Gadgets for Microsoft Visual Studio 2005
Currently this is my favorite free tool. There are a bunch of cool features in this, but I have three that are my favorite:
1. Line ruler - Places a "ruler" highlight across your current line (where the cursor is) and has tick marks to indicate the editor's indentation levels.
2. Indentation guide - Draws a vertical bar in the editor indicating the indentation level of the current line.
3. Command Spy monitors command execution and allows you to see exactly what commands you've run, how many times you've run them and what key bindings are used to invoke those commands. The main purpose of this tool is to allow you to learn what commands are bound to which keystrokes, so that you can work faster within the IDE.
4. The SLOC Report tool provides an easy way to count the lines of code. The line count is divided into three categories: code, comments, and whitespace. Once the lines of code have been counted, the results are drawn as a pie graph.


XML Notepad 2007
This is simply a great tool for working with xml documents. It's simple to use, just open up your document with XML Notepad 2007 and start edition. If you used the original version then you're in for a treat. Here are the features that have been added to the version:
1. Incremental search (CTRL+I) in both tree and text views, so that as you type it navigates to the most matched node.
2. Cut/copy/paste with full namespace support in a simple interoperable XML format.
3. Drag/drop support for easy manipulation of the tree, even across different instances of XML Notepad and from the file system.
4. Infinite undo/redo for all edit operations.
5. In-place, pop-up, multi-line editing of large text node values and IntelliSense based on expected elements and attributes.
6. Configurable fonts and colors via the options dialog.
7. Full find/replace dialog with support for regex and XPath expressions.
8. Good performance on large XML documents (loading a 3 MB document in about one second).
9. Instant XML schema validation while you edit with errors and warnings shown in the task list window.
10. Support for custom editors for date, dateTime, time, and color datatypes.
11. HTML viewer for displaying XSLT transformation results.
12. Built-in XML Diff tool.

XPathMania
Hate writing XPath? For me hate is an understandment. This is a nice little add-in that will show up as a tool window in Visual Studio. Open up an xml document you want write xpath against in the editor window then start writing your query in the XPathMania window. I found this to be a huge time saver.

Bootsrapper Manifest Generator
If you don't know or haven't created custom bootstrappers for Visual Studio 2005 then you don't know what you're missing. You can get a taste of it here. If you have created bootstrappers you know the pain that can come with trying to generate the necessary manifests for the boostrapper to work correctly. This is a nice GUI that will walk you through the steps of creating a manifest for your bootstrapper. A word of caution, I've had mixed results with the manifests that get generated. I find that I usually need to make a manual tweak or two (using XML Notepad 2007 of course) and then I'm up and running. One of my upcoming posts will dive into the boostrapper functionality in depth, so stay tuned.

Sandcastle and Sandcastle Help File Builder
When .NET 2.0 came out we all shed a tear when NDoc failed to keep up. I know some of use have been using Doxygen to generated documentation form code, but it wasn't really built to work with C#. Enter Sandcastle. This is Microsoft's command line tool you can use to turn your code comments into nice help file documentation. It's great MSFT has stepped up to fill the void, but the command line is a pain to use. There's a sample here, but I have yet to get it to work successfully. Feeling these frustrations a couple of guys created a GUI and called it the Sandcastle Help File Builder. There are loads of nice features with the GUI, but here's the two I like best:
1. The GUI interface is almost identical to the NDoc interface so anyone familiar with NDoc should be quite comfortable using it.
2. The settings are saved in a project file and the help file can be built from within the GUI or you can add a step to your MSBuild process that runs the command line tool to build it for you using the same project file.

If you haven't seen this yet, I recommend checking it out.

CopySourceAsHtml
First, ignore the horrible formatting of the site where this tool can be found. I think the developer made it look so bad just to show what the tool can do. I haven't used it a whole lot but it's pretty cool. If you right-click on some selected code in Visual Studio you'll get a Copy as Html option.

Well I didn't mean to ramble this long and I didn't event get to the cool mock object tools I've been playing around with. I guess that will have to wait for another day.


ag

1/19/2007 8:49:27 AM (Central Standard Time, UTC-06:00)  #    Comments [0]   .NET Development | Tools  |  Trackback
 Monday, January 15, 2007

Let me preface this by saying I hope you never run into this problem.

So back to the question "When is zero not a number?" Simple when you try to convert a string of zero (i.e. "0") to the number zero (i.e. 0) and you have a corrupt registry entry.

Allow me to explain. At a former client a development team was beginning to roll their .NET 2.0 code into test when the following error was encountered on an intermittant basis:  "Input string was not in a correct format".

After a bit of debugging on the client machine I found the error was encountered when code similar to the following was executed:

string myString = "0";
int myInt = int.Parse(myString);

(I could go into why this code was in place, but that's a topic for another entry.)

It was obvious that something on the machine wasn't quite right as this conversion should happen without problem. However, locating the problem wasn't easy due to two factors:
1. Another user could log on to the same machine and run the above code without problem.
2. The application was being rolled to an initial group of 10 machines, but the problem didn't occur on every machine.

The bigger issue faced by the team was that this application was going to be deployed to thousands of client machines. With a problem like this in place, the potential deployment of the application was at risk.

After hitting my head against the all for a week or so I ran across the following article: http://support.microsoft.com/kb/919236. While the issue was with the SQL Server 2005 Management Studio, the symptom sound similar. According to the article the cause of the problem has to do with the HKEY_CURRENT_USER\Control Panel\International\sPositiveSign being corrupt. I took a look at the key on the machine and the value looked OK. However, I removed the key, recreated it, and the problem was resolved.

Unfortunately, I was never able to determine what corrupted the key. My suspicion was that an update pushed by the client's IT group corrupted the key. However, I was not able verify this. So, if you know of an app or update out there that corrupts this key let me know (it'll help me sleep better at night).

Like I said...simple.

ag

1/15/2007 9:31:25 PM (Central Standard Time, UTC-06:00)  #    Comments [0]   Exceptional | .NET Development  |  Trackback
Copyright © 2008 RBA Consulting.