LP on .NET

June 19, 2009

Development Environment Install Log

Filed under: .NET,Software Development,technology,Visual Studio — Larry Parker @ 3:58 pm

I’ve been programming for over twenty years, but it wasn’t until the last couple of years that I became disciplined enough to maintain a log of what I install on my development machine.

It’s amazing how useful an audit trail like this can be over the course of several months:

 

06/11/2009

– Installed XP SP2 Support Tools

    Installed from http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en

    Installed into C:\Program Files\Support Tools\

05/29/2009

– Installed Sandcastle May 2008 Release (Version 2.4.10520)

    Installed from http://sandcastle.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=13873

    Installed into C:\Program Files\Sandcastle\

Last Fall I got a new development machine at work and it was a simple matter to reinstall exactly what I needed by following the entries in my log.

It’s also useful for troubleshooting problems that seemingly come out of nowhere and inevitably get traced back to the latest CTP you just installed (well, now I use virtual machines for those).  🙂

The extra couple of minutes it takes to record the changes in the log can sometimes be annoying, but I have found that it is well worth the time and effort.

Advertisements

June 11, 2009

Wireshark

Filed under: Networking,technology — Larry Parker @ 10:48 pm

If you need a good packet sniffer, Wireshark is a very handy utility, and the price is right (free).  You can download it here.

I used it all day at work today to look at packets going across the wire sent from my WCF code.  It was especially useful to verify that SSL transport security was indeed activated.  I could see the Client Hello and Server Hello handshake in action and also verify that the packets were encrypted (whereas prior to using SSL I would see the plain-text SOAP messages).

I’m really impressed with how Wireshark displays the packets and breaks them up into the various Internet Protocol Suite components (e.g. Ethernet Frame II, IP, TCP, etc.).  It’s a great learning tool.

Cannot Paste into Microsoft Virtual PC

Filed under: Microsoft,technology — Larry Parker @ 4:18 pm

I’ve been using Microsoft Virtual PC 2007 for various things, and it’s been working well.  But one thing that really annoys me is that I can’t copy from my host desktop machine and paste into the virtual PC (nor can I copy from the virtual PC and paste into the host machine).  This has become frustrating enough that I finally googled it and came up with this article.

The simple workaround is to just Remote Desktop into the virtual PC.  Works for me!  🙂

Windows XP SP2 Support Tools and httpcfg.exe

Filed under: Microsoft,technology — Larry Parker @ 11:51 am

I’m doing some work with WCF and SSL and need to configure a port with an SSL certificate on the server.  To do this, you need the httpcfg.exe utility, available with Windows XP SP2 Support Tools.

So I downloaded it, installed it, looked in C:\Program Files\Support Tools, and no httpcfg.exe.  What’s the deal?

It turns out that when you install Support Tools, you need to select Optional Tools from the setup wizard (it’s disabled by default).

untitled

So just make sure you select the feature to get httpcfg.exe (and the other optional tools).  Hope this helps.

June 10, 2009

Generating Method Stubs in Visual Studio

Filed under: .NET,Microsoft,technology,Visual Studio — Larry Parker @ 3:17 pm

I’ve been using Visual Studio for years and just stumbled upon a very useful feature – generating method stubs.  You can read more about it here, but say you’re in the middle of coding and want to call a method that you haven’t written yet.  That’s what I was just doing a few minutes ago, but instead of doing the usual and moving out of the current block of code in the editor to create a new method, I decided to just code the method call the way it seemed it should be.

Then I right-clicked on the method call for the unwritten method, and to my delight I saw this:

untitled

A Generate Method Stub menu item gets added to the context menu!  I clicked on it and the following code was automatically generated for me:

private static XElement TransformQueryElement(ushort queryNum, XElement origQueryElem)
{
    throw new NotImplementedException();
}

Exactly what I needed!  Thanks Microsoft.  🙂

June 1, 2009

Funny NullReference Documentation

Filed under: .NET,Humor,technology,Visual Studio — Larry Parker @ 2:01 pm

Here’s some funny documentation I saw via Intellisense while creating a NullReferenceException:

untitled

And this whole time I thought my exceptions were being read by monkeys!  🙂

May 28, 2009

Domain Account Login Problem on Virtual PC

Filed under: Microsoft,technology — Larry Parker @ 3:45 pm

I just tried logging into a virtual PC of mine (Microsoft Virtual PC 2007) using my domain account at my company and got the following error:

untitled

My domain account worked before, so something must have changed but I couldn’t figure out what.

A quick Google search turned up this article which describes the same problem I was having, including the solution.

Turns out that you just need to take the virtual pc off the domain and then rejoin.  Now I’m in business!

But you still need a way to log into the virtual pc with administrator rights, so it’s important to have a local account for that.

Hope this helps.

September 7, 2007

LINQ is Fantastic!

Filed under: .NET,LINQ,Orcas,technology — Larry Parker @ 2:15 am

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!

September 1, 2007

Microsoft Expression Blend

Filed under: .NET,Orcas,technology,Visual Studio,WPF — Larry Parker @ 12:47 am

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!  🙂

August 7, 2007

.NET Garbage Collection

Filed under: .NET,technology — Larry Parker @ 12:41 am

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.

Next Page »

Blog at WordPress.com.