8/28/2009

How to minimize MSN Messenger to the system tray in Windows 7

Filed under: Developing .NET, Software — Guus @ 9:55 am

Just installed my new laptop (with SSD, yeah!) with Windows 7. It’s sweet and running smooth. Only one of the things I noticed that MSN is not minimizing to the system tray anymore. A colleague of mine forwarded me this url, which actually helps:

http://windows7center.com/tutorials/how-to-minimize-msn-messenger-to-the-system-tray-in-windows-7/

Another thing I noticed, was that I received weird COM messages from my Visual Studio. Like ‘team foundation error creating an instance of the com component with clsid’.
It’s caused by a collaboration setting in the TFS pane of VS. A solution for the class error is posted here.

Hope this helps..

8/10/2009

Help with LINQ

Filed under: Common interest — Guus @ 9:51 am

Ever wondered how the syntax of a LINQ query should be written. Most queries are simple to write. But how about a count or a range in a query. To quickly lookup how you can do things like this, I found this page:

http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

Have Fun!

8/4/2009

Remote Desktop connection – disable the timeout

Filed under: Common interest — Guus @ 9:59 am

Sometimes you have to copy some files via RDC since no FTP is available. If the files are big, it can take a while, since file transfer can be slow. Often the connection can be disconnected since RDC ‘thinks’ that there is no activity between client and server: the file transfer is lost and you can start all over again. :-(

To prevent this you can alter the configuration and enable the TCP KeepAlive setting. To enable TCP Keep Alives, open the Registry on your TS servers and navigate to HKEY_LOCAL_MACHINE\ SYSTEM\CurrentControlSet\Control\T­erminal Server. Then create a new key called KeepAliveEnable with a DWORD value of 1.

Beware: remember to remove it, to increase security..

7/28/2009

Firefox 4.0 early screenshot revealed

Filed under: Common interest — Guus @ 9:52 pm
firefoxlogo[1] Just browsing my some of my favourite sites and came across a nice article about the new Mozilla Firefox. It’s still futuristic talk, but I liked the designs (and the article). So here a link to the blogpost of Ben Parr.
6/22/2009

So Shumi is the Stig…

Filed under: Common interest — Guus @ 11:26 pm

vlcsnap-208176

Well, is he really??

vlcsnap-207370

Why is he mentioned besides the Stig?? Maybe it’s because he is the only one allowed in the Ferrari FXX? To promote the car by giving it the fatest lap (7 seconds faster then the really fast German car Gumpert?). Maybe we know more after the next episode of Top Gear.

6/11/2009

Running your .NET app for the 1st time in IIS7: blank page?

Filed under: Common interest — Guus @ 9:33 am

Today I spent some time to discover why my site wasn’t working locally in my new Vista / IIS7 setup.

Symptom:

This is what I did:

  • Checked out the solution from Team Foundation Server
  • Upgrade my Web folder to be an application (choose ‘Convert to Application’ option from the IIS7 context menu)
  • Reloaded the web project in VS2008 and build the solution
  • Opened the url in the browser… Blank page! No html at all.. not even an error message
  • After looking in the log files and event viewer, I saw 500 status code errors.
Problem:

To save you –dear reader- some time: it’s caused by the malformed web.config (according to IIS7, in IIS6 it was working fine). It appears that IIS7 has fundamental new features over IIS6 and introducing breaking changes while upgrading.

Solution:

There are 2 ways to deal with this problem:

  • Upgrade the web.config to IIS7 level ~ this is recommended, since you can use the new features. Only I don’t now if it’s IIS6 backwards compatible (beware of other developers or deployment to IIS6 servers). You can read more about this on Mike Volodarsky’s blog.
  • ASP.NET 2.0 applications on IIS 7.0 are hosted using the ASP.NET Integrated mode by default. You are able to switch back to can change this to run ASP.NET applications using the legacy Classic ASP.NET Integration mode, which works the same way as ASP.NET has worked on previous versions of IIS.

I used –for now- the last option. On webapplication level you can set the Application Pool from ‘DefaultAppPool’ to ‘Classic .NET AppPool’. Restart IIS7 after changing this. (Another way is to change the DefaultAppPool to run in Managed Pipeline Mode ‘Classic’ instead of ‘Integrated’)

Hope this helps,

Guus

6/9/2009

Analyzing IIS log files

Filed under: Developing, Software — Guus @ 2:40 pm

Imagine that you need certain detailed information from your IIS log files in a period of time, let’s say for a month.

When I lookup the log directory* of my website, I discovered lots of files with a size of 30 MB per day. Over a couple of years the directory size has grown up to 103 GB (in a compressed folder fortunately). So for 1 month I have 31 files * 30MB = 930 MB’s of log data to process. That’s a lot!!

How about a tool that can help you query these files with SQL statements? Yes, there is: Microsoft LogParser. It’s able to analyze different Log files and File formats. It’s not primary designed for IIS, but can be used to analyze other formats and to different output formats. Sometimes a picture says more than words:

Logparser is a command line tool but there are GUI’s available. Tip: when using commandline, use notepad for creating queries and copy/paste them into the logparser. The basic commandline syntax is: logparser "(sql clause)" -rtp:-1

Time for some example. For IIS logs, you need to know the W3C Extended Log fields for building your query. In the first example, we want a list of HTTP errors ordered by url, status and occurence count:

SELECT cs-uri-stem AS Url, sc-status AS Status, COUNT(*) AS Errors 
INTO errorlist.csv
FROM D:\IISLogFiles\W3SVC492050629\ex090601.log 
WHERE (sc-status >= 400) GROUP BY Url, Status 
ORDER BY Errors DESC

This query only looks in the log file of 1st of June 2009. If you want a complete month you can change the filename with a wildcard: ex0906*.log for all of June. The INTO statement declares that the output should be stored in a CSV file. When INTO is omitted, the output is shown direct in the console. The output looks like this:

Url                                                                  Status Errors 
-------------------------------------------------------------------- ------ ------
/favicon.ico                                                         404    800
/Web/Site/images/spacer.gif                                          404    64
/robots.txt                                                          404    47
/web/site/favicon.ico                                                404    43
/web/site/images/spacer.gif                                          404    29
/mediaserver/web/Styles/MK/images/header/reg.gif                     404    19
/mediaserver/web/Styles/MK/images/header/fpwd.gif                    404    10

Hmm, maybe I need to add a favicon.ico and a robots.txt for this site :-) If I use this command for ex0906*.log the execution time of processing 930 MB is 160 seconds (2:39). It returns 122 unique URI and processes 3.649.554 log lines. So it’s incredibly fast!

Another query I use often is for seeing who called a specific URL and at what time:

SELECT date,time,c-ip,cs-uri-query 
INTO resultlist.csv 
FROM D:\IISLogFiles\W3SVC492050629\ex0906*.log 
WHERE cs-uri-query like ‘m=module&a=action&name=enquete_%’

This query parses all log files of June and outputs to resultlist.csv all the loglines that have cs-ui-query starting with ‘m=module&a=action&name=enquete_’ .

There a more interesting Log Parser examples mentioned on Code Horror blog site of Jeff Atwood.

*Mine was stored in D:\IISLogfiles\W3SVC492050629. A little sidestep: it’s on the D partition, so the the C system partition cannot run out of space. And the number 492050629 corresponds to website ID in IIS Manager.

3/28/2009

What’s in the box?

Filed under: Common interest — Guus @ 11:43 am

The creator of this Science Fiction test film is Tim Smit. He is a dutch student and has had several phone calls from the American film industry.

Amazing what people can do with 150 euro’s and a pizza (and a few weeks spare time..).  The creator was interviewed on the national Dutch Television

What to do with old vinyl records?

Filed under: Common interest — Guus @ 11:06 am

Found a nice site via StumbleUpon about DIY: unwanted vinyl record projects:

Hmm, I have to go to a flea market, to get some of those :-)

3/27/2009

.NET design principles

Filed under: Developing, Developing .NET — Guus @ 5:44 pm

Yesterday evening I visited the dutch dotNed usergroup meeting. The topic of the evening was Design Patterns & Testability.

The presentation was held by Dennis Doomen of Aviva solutions. He started with a quote about good design & testability:

“I don’t care how good you think your design is. If I can’t walk in and write a test for an arbitrary method of yours in five minutes its not as good as you think it is, and whether you know it or not, you’re paying a price for it.” - Michael Feathers

He made some effort to remind everybody about good coding principles and design patterns. The part which I found interesting was about Design Principles. I summarize them here (also for myself to remember them):

Single Responsibility Principle ~ a class should only handle and be responsible for one specific task. Example: a configuration manager should not connect to webservices, send e-mails, grabbing data, etc.

Decrease Coupling, Increase Cohesion ~ Class only does the things it is supposed to do. Should work closely with other classes.

Open Closed Principle ~ software entities should be open for extension but closed for modification.

Liskov Substitution Principle ~ Let’s say you have an entity that is responsible for specific business process and it consumes data from a database. The L.S.P. states that when you would like to change from one data source to another (let’s say XML files) it should not inflict changes in your entity. The most common way is to realize this is by using interfaces.

The Law Of Demeter (LoD) ~ a.k.a. “Only talk to your immediate friends.” The basic idea is to avoid invoking methods of a member object that is returned by another method. Bad smell:

   1: int sumOfFirstOrder = Customer.GetById(0).Orders[0].TotalAmount;

Fairly easy to recognize: long code line with a lot of dots..

Last Responsible Moment a.k.a. Reversability ~ Quote of Jeremy Miller says it all:

The key is to make decisions as late as you can responsibly wait because that is the point at which you have the most information on which to base the decision. In software design it means you forgo creating generalized solutions or class structures until you know that they’re justified or necessary.

YAGNI ~ stands for You Ain’t Gonna Need It. Programmers should not add functionality until it is necessary. So always implement things when you actually need them, never when you just foresee that you need them.

Read more about YAGNI here.

Query Command Separation ~ It states that every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, asking a question should not change the answer. So no surprises like this:

   1: public int Count
   2: {
   3:     get {
   4:         _count = _count + 1;
   5:         return _count;
   6:     }
   7: }

So a getter, should only get and not perform modifications. Create an increment method if you want it to increment!

Tell, Don’t Ask ~ I forgot this one, so probably it wasn’t that important.

Recommended reading: a design principle article by Jeremy Miller