WorkingSet vrs WorkingSet64

Recently I’ve been doing a lot of work with the Process.GetCurrentProcess() method and since the application I am building is being developed on the 2.0 64bit framework, I was worried that if I used Process.GetCurrentProcess().WorkingSet64, that the application wouldnt work with 32bit OS’s, since WorkingSet was deprecated, but not enforced.

After some thought though, I realised that the WorkingSet returns the amount of memory being used by the process as an integer (32 bit signed integer). OK, so the maximum value of an integer is 2,147,483,647 — which is remarkably close to the total amount of memory that a process can have in its working set.  Except, there is actually a switch in Windows that will allow a process to use 3 gig of memory instead of 2 gig.  So what would happen when you poll the WorkingSet you will get a negative number, a really big small negative number. Usually, in the realm of -2,147,482,342.  As the more perceptive of you have guessed the problem already.  The overflow bit.

So you ask, why didn’t Microsoft just change the API so WorkingSet returned an Int64 instead of an Int32.  Well they could, except that they would break applications built against version 1.0 and 1.1 frameworks, as this post explains.

But after all this pondering, it turns out that WorkingSet64 des exactly what WorkingSet does, except returns an Int64 instead – and as such is less prone to breaks.  Works with both 32bit and 64bit Windows and Frameworks and all is good with the world.

Install A .Net Service Via Command Line

I’ve been working with .Net services for the last few years or so and it is often convenient for debugging to be able to install your debug version. Since it is a major pain to build an installer every time we want to test, we used the command line utility InstallUtil.exe that comes with the .Net Framework to install and uninstall our services in batch files.

If you’ve installed .Net in the default location InstallUtil.exe lives in C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe
in the respective framework version directory.

Below is an example batch file.

C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe [your-service.exe]

and to uninstall, use the /u flag

C:\Windows\Microsoft.Net\Framework\v2.0.50727\InstallUtil.exe /u [your-service.exe]

Using these batch files we just create short cuts to them and can double click the short cut to install or uninstall. Of course you can install/uninstall more than one service in the batch file.

Be sure to also check out the other flags available for InstallUtil.

Fantastic .Net Design Pattern Examples

Design patterns are recurring solutions to software design problems you find again and again in real-world application development. Patterns are about design and interaction of objects, as well as providing a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges.

The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns, and the website contains an awesome set of .Net examples for each of the patterns.

Extending Explorer with Band Objects using .NET and Windows Forms

One of the great things about Firefox, is how easy it is to extend. Internet Explorer and Windows Explorer, not so much.  If you’re a ATL or COM guru then you might not find it so hard, but for those of us from a Managed Code background; its like splitting wood in your eyes.

A while ago I found a great article on CodeProject by Pavel Zolnikov, which walks you through the implementation of an Explorer bar with the help of BandObject base class. Describes implementation details of the BandObject class.

This was excellent, but it really didn’t work using the .Net 2.0 framework – that is until I found this little gem Band Objects – .NET 2.0 Redux.

Automatic Update – Yeah!

Cross-posted from the Particls blog.

I got the auto update library and executable working tonight for the (currently somewhat unstable) “experimental” build of Touchstone. It’s well overdue because our little application is getting quite complex now and laying in new features can be a tricky process. Now we have a mechanism to automatically and non-invasively update users with new versions – making adoption and user updates quick, seamless and easy.

Now perhaps Chris won’t kick my ass so hard when a Private Alpha release starts throwing those ugly “object not set to reference of an object” exceptions.

Now all I need to write is a program which automatically updates the blog for me, and I’ll be right!

I just did something very stupid but Chris still loves me

Cross-posted from the Particls blog.

I just opened a .vb file from another project, and upon closing the window (and subsequently not saving) I realised all too late, that Visual Studio had in fact oped the file inside the Touchstone project. You can probably guess the outcome. So off I go again, recoding the complete structure of the BagItAndTagItParser class – be assured that I wont be opening any “stray” .vb files for the rest of the day! Chris is ok with this though, because we just implimented the first ticker system and its actually reasonably functional!

It’s interesting, starting this project has opened my eyes to a whole subculture of RSS, which I was previously unaware of. I think that reading the excellent intellect of Nick (from FeedDemon) and others regarding some sort of solution to the growing ADD (Attention Deficit Disorder) is inspired.
With the rapid expansion of content sources, the more ways we can think of to manage this content without hindering productivity (I am a pragmatist after all) is where we need to redouble our efforts. This is the philosophy behind Touchstone – and I’m coding as fast as I can. Aside from the heavy setback today, I should have the Bag it and Tag It Parser complete before the coding marathon tonight. If you feel inspired enough to chat with us through comments on this blog, please do – we like to feel popular.