Monday, December 27, 2004

412.aspx

Disaster relief from donating bloggers

We had a scary day yesterday as a very close friend of us is on vacation in Sri Lanka. Luckily it turned out that she was in the middle of the country and was unaffected by the disaster. I was wondering what we can do to help the victims of the earthquake and tsunamis when I came across this post by Greg Hughes



"This is the right time to stop what you normally do, get out of your little digital world that you assume is all-defining and all-encompassing (it’s not, really) and come back to reality...Very real people are experiencing very real pain, and you can do your part to help them recover."


Nick Bradbury is donating what he earns from TopStyle and FeedDemon to the International Red Cross. I know it is not much, but I will donate what I get from Google AdSense in December from my blogs Crap And Crapability, Cool Or What and /egilh to the International Red Cross.


I hope more bloggers follow the example of Dan Gilmore and donate what they can to help, or let Scob know if they have other suggestions for helping.

Wednesday, December 22, 2004

403.aspx

10 Tips for Writing High-Performance Web Applications

The January 2005 edition of MSDN Magazine has a list of tips for writing high performance ASP.NET applications.


Nothing new, but a useful reference for people that are new to ASP.NET development.


 Via [MSDN Just Published]

402.aspx

VMWare 5.0 Public Beta

VMWare is very useful when testing playing with the latest and greatest betas or developing software that can will break your machine. There are several new features in VMWare 5.0:



  • V2V Assistant: Creates VMWare Virtual Machines from Microsoft Virtual PC virtual machines

  • Movie Capture of all the operations you do in the virtual machine

  • Performance Enhancements

  • Support for 64-bit Hosts

It can be download from the BetaNews FileForum


Via [BetaNews

Thursday, December 16, 2004

400.aspx

How and why people use camera phones

Microsoft Research has researched the use of Cameraphones. I'm about to get my first camera phone tomorrow, a Nokia 6630. Wonder what kind of user I will be.



In this paper we describe an in-depth study into how people (adults and young people) use their camera phones. Using a combined method of interviews and grounded discussions around a sample of actual photos, we look at people's intentions at the time of capture, subsequent patterns of use, and desires for future technology. The result is a 6-part taxonomy which provides a framework for describing the way images are used both for sharing and personal use, and for affective (or emotional) reasons and functional use. On the basis of this framework, we discuss the value of camera phones and point to ways in which future design may encourage its emerging value.


One thing is for sure: I can think of one occasion when I really wanted to have a camera handy!


I have used a Nokia 6600 the last few weeks while I am waiting for the replacement for my broken phone. Didn't use the camera much but I got the chance to try it the last time I was in London waiting for a flight.


Via [MSDN Student Flash]

Wednesday, December 15, 2004

398.aspx

SqlClient has a Max Pool Size setting of 100

Another lesson learned: Increase the Max Pool Size setting on systems that does a lot of requests to the DB if you use ADO.NET


I had problems earlier this week with a custom session management system that handles 15.000.000-20.000.000 requests per day per machine but is designed to handle a lot more.  The DB is pretty well optimized so call times for each query is only a few milliseconds in normal conditions. With 17.500.000 requests per day there are ~200 requests per second to the session management system with peaks that are a lot higher due to traffic distribution throughout the day.


I didn't realize that the ADO.NET Sql Client by default uses max 100 items in the connection pool. I expected it to grow the connection pool as needed to handle the increased traffic. I was wrong. When it reaches 100 connections it starts queuing requests. With >200 req/s it quickly reached the 100 item limit when the DB slowed down during batch operations.


The system scales a lot better with increased traffic after we doubled Max Pool Size setting in the SqlClient ConnectionString like this: 



Data Source=...;User ID=...;Password=....;Initial Catalog=...;Min Pool Size=10;Max Pool Size=200


 

Monday, December 13, 2004

388.aspx

Koders.com

Koders.com has tons of source code. Great if you're looking for ways to use a particular function, how to manage a particular error code or if you look for an implementation of a particular algorithm.


The search results can be filtered by language as well as license.


 

385.aspx

Google Suggest: Better than Auto Complete?

Impressive. The Google Suggest beta does a great job of auto complete for the .NET APIs:


382.aspx

The Holy Title of Software Architect

The To Software Architects: Serve End Users, Not Your Egos article on DevX is something to keep in mind for all software architects.



At one organization, they had a diagram on one wall that was 14 feet long and 4 feet high with tiny print. The architect was so proud of his masterpiece, his brilliance, his grand work. Minor amounts of investigation revealed that none of the team leads had the slightest clue what this massive diagram really meant, but it sure looked cool and impressed the executives when they visited the development area.


Individual developers had received smaller diagrams, filled with blocks and arrows, that told them exactly how to build their piece of the application. While attempting to interpret the diagrams, they had to resort to Googling the obscure patterns referenced and were made to feel incompetent for not knowing what a "Grafter" pattern was. Diagramming is about communicating what you're building, not about conveying your ability to memorize obscure names for common solutions.


I'm sad to admit that I see this behavior at work as well (I guess you better stop reading if you work with me:-) What do you tell a developer that proudly brings you the latest creation: a UML diagram that implements that latest and greatest patterns for something that can easily be done single class? Most of them do it to seek approval and show how much better they are than the other developers. Others suffer from the beta syndrome: the need to use the latest and greatest technologies and software.


I do my best to KISS every day as long as it doesn't hurt performance too much.  Keeping it simple has several benefits:



  • It contains less bugs

  • It is easier to maintain

  • It is easier to explain the design to the developers.

Or in the words of David Talbot:



If you're in charge of the software architecture, whether or not you've been bestowed the holy title, keep the focus on designing a system that works. Keep your diagrams simple and understandable. Don't pay too much attention to whether or not it is a proper Booch diagram or whether it utilizes GoF patterns. Don't try to micro-design every developer's piece of the whole, just where it integrates into the whole. Build the system to do what it needs to do, don't gold plate what the users will never see nor care about.


Just build good software on time and within budget.

Thursday, December 9, 2004

379.aspx

Pocket PC .NET CF encryption

.NET comes with a wide range of  cryptography options. The story is different on the .NET Compact Framework as cryptography routines have been removed from the .NET CF runtime to save precious memory.


Cryptography is an interesting subject in itself so I decided to port AES/Rijndael, the 3DES replacement, to C#. The official AES site links to sites with AES implementations in many different languages. I had a look, and decided to port Mike Scott's C implementation to C# and add some routes.


Download .NET CF C# AES source code


Next step for the Pocket PC password manager will be an encrypted CSV dataset or stream.

378.aspx

Ahhh! What a great start of the week: 3 days at home

Tuesday was a public holiday in Milano and Wednesday was a public holiday in all of Italy. I took Monday off so I have had 5 days working at home on “hardware” stuff: building a set of stairs, making a new room in the cellar, fixing the gate, hanging up Christmas lights and decorations with the kids.


Another week or so at work and I'm off for Christmas vacation. What a relaxing way to end the year :-)

Wednesday, December 1, 2004

371.aspx

Larry's Coding Conventions

A great, easy to follow, guideline for coding style.


I was surprised to discover that I'm using the same coding style in C# as Larry Osterman uses in C/C++ with some minor exceptions:



  • I start method names in lower case, i.e. I use printError instead of PrintError, (leftover from my Java days)

  • I ALWAYS put the constant part of an evaluation on the left: if (S_OK == result) is safer than if (result == S_OK)
    I know it doesn't really matter that much in C# as the compiler warns you but; better safe than sorry.

For some reason I end up swapping back to hungarian notation when I program in C/C++ for Windows. I guess I can "blame" Programming Windows by Charles Petzold for that :-)


 

Tuesday, November 30, 2004

365.aspx

Lycos attempts to fight SPAM with DDOS

Fighting evil with evil.


BBC reports on Lycos latest attempt to fight SPAM:  The Make LOVE not war screen saver (Flash needed)


The idea is pretty simple:



  • Scan SPAM for link to web sites

  • Manually verify that the web site sells spam goods

  • Let the screen savers send tons of request to the spam web sites

Each client only generates 3-4MB of traffic but Lycos expects to generate terabytes of traffic making the spammers pay extra for high bandwidth usage. If it makes them "hurt where it counts" I guess it does some good but I still think it's better to stop SPAM before it leaves your LAN. Their approach doesn't stop spam and it doesn't even prevent it from coming to your inbox and breaking your balls. All it does is generate loads of traffic and make their web site slower. The spammers will continue to send mails as fast as before but the client who paid for the "direct e-mail marketing" will pay dearly as he gets hits by the Lycos DDOS.


Wonder how long it takes for the biggest spammers to sue Lycos?


Via [SmartMobs]

Sunday, November 28, 2004

363.aspx

.NET CF DataSet performance using XML, text and CSV

I want a fast storage for my secrets that is easy to synchronize with a PC. The obvious choice would be a DataSet serialized to an XML file. It's fast on a PC but my SMS Manager slows down on the Pocket PC when the DB grows. The password manager will be used for reading in 99% of the case so I set up a simple test suite on the PPC to test the performance of the different file formats I was considering:



  • Text array: reads a line and does a .Split() using tab as the separator. Creates a  2 dimensional array (rows/fields in row)
  • CSV array: parses CSV file and creates a  2 dimensional array (rows/fields in row)
  • XML dataset: uses the ReadXml() method of the DataSet object
  • CSV dataset: parses a CSV file and builds a DataSet in memory


Example test routine (XML DataSet):


openFileDialog.Filter = "XML Test|*.xml";
if (DialogResult.OK == openFileDialog.ShowDialog())
{
    string fileName = openFileDialog.FileName;
    int startTick = Environment.TickCount;        
 
    System.Data.DataSet ds = new System.Data.DataSet();
    ds.ReadXml(fileName);            
    int ticks = Environment.TickCount - startTick;
    System.Windows.Forms.MessageBox.Show("Time taken: " + 
            ticks + " ms");
}

I know that DataSets serialized to XML are slow on .NET Compact Framework but I had no idea they were this slow:


The test were run with 1.000 records on a H3870.  I repeated the tests with 100, 1.000 and 10.000 records with similar results.



I find it strange that my CSV version is almost 3 times faster than the text version that does a simple Split(). This is the Text reader core:


StreamReader sr = File.OpenText(fileName);
String input;
while ((input = sr.ReadLine()) != null )
{
    rows.Add (input.Split(fieldSeparators));
}
sr.Close();

The text version is slightly faster than the CSV version the first time it is run (not shown in my graphs). I guess this is because the String class is pre-jitted.
I have decided use the CSV DataSet for several reasons:



  • It gives me all the features of DataSets I would otherwise have to implement myself for the array versions: sort, filter, search
  • It has less start up overhead for the first call (728 ms vs 2.218 ms for XML)
  • It has acceptable performance up to 10.000 records (6.303 ms vs 36.513 ms for XML)


I will play with encryption support next.

Friday, November 26, 2004

361.aspx

A Password manager for my PC and Pocket PC

I always use strong passwords which means they are close to impossible to remember. I can store my 200+ passwords and other "secrets" encrypted on a my PC but I sometimes need them on my Pocket PC as well.


Password Safe meets most of my requirements:



  • It's free and comes with source code 

  • Pocket PC and PC version

  • Copy password to clipboard without displaying it

  • Auto paste/type in the PC version

  • Tray icon

  • Strong encryption

  • All data protected (i.e. there is no clear text data in the file) by a single master password

  • Simple and fast to use

  • Import text or csv

The latest PC version, 2.0.7, is perfect but it is not compatible with the latest Pocket PC version which is stuck at 1.9.2. The old 1.9.2 version for the PC is missing some of the must have features:



  • Tray icon

  • Auto type

  • Import (I am -not- retyping 200+ items)

So, the options are:



  • Update the open source Pocket PC version to 2.0.7

  • Write my own

The Pocket PC version is written in C++ using MFC which I haven't used in a while so it should be faster, and more interesting, to write one from scratch. So, I will implement my own password manager in .NET and post post code sniplets as I write the core parts of the application that may be interesting for other people as well:



  • Fast encrypted DataSets on the Pocket PC

  • Clipboard integration on the Pocket PC

Tuesday, November 23, 2004

355.aspx

Safe online banking with two factor authentication

Cool idea: authenticating large bank transfers via SMS.



ASB and Bank Direct's internet banking customers will need to have their cellphone close to hand if they want to use the net to transfer more than $2500 into another account from December.
ASB technology and operations group general manager Clayton Wakefield announced the banks would be the first in New Zealand to implement a "two factor authentication" system to shut out online fraudsters, unveiling details of the service on Friday.


After logging on to internet banking, customers who want to remit more than $2500 into a third party account will receive an eight-digit text message to their cellphone, which they will need to enter online within three minutes to complete the transaction.


Italy is still far behind but things are improving:



  • CartaSi (credit cards) sends SMS alerts in seconds when your credit card is used.

  • BMP (banking) is increasing its security by requiring you to enter a code from a pre-generated list in addition to the user name and password for any online transaction.

Via [Schneier on Security]

353.aspx

Pocket PC .NET CF development tips & tricks

The new Optimize Your Pocket PC Development with the .NET Compact Framework article in the December 2004 MSDN Magazine has several usefully .NET CF tips and tricks:



  • Tips for making programming in the .NET Compact Framework environment easier

  • Tricks for making your Pocket PC-based apps run faster

  • Important .NET Compact Framework classes

  • .NET Compact Framework windowing issues

Full source code available on line

Monday, November 22, 2004

350.aspx

Avalon Community Technical Preview

"Avalon" is the code name for the presentation subsystem class libraries in WinFX. MSDN Subscribers can download the November 2004 Community Technical Preview. It runs on Windows XP as well as Windows 2k3. It requires .NET 2.0 beta which I already have on my machine for another cool beta: MSH


More information on the MSDN article on Avalon November 2004 Community Technical Preview and the Avalon news groups:



Update: Forgot to add XamlPad which allows you to play with XAML after installing Avalon.


Via [frankarr] and [simplegeek]

Friday, November 19, 2004

344.aspx

Skulls Trojan on Symbian

Not the first trojan for Symbian phones but one of the first that is out in the wild. From the F-Secure report on the Skulls Trojan



This trojan has been distributed on some Symbian shareware download sites as "Extended Theme Manager" by "Tee-222". If you see it, don't install it on your phone. It will make you're phone useless and it will prevent it from booting up. Recovery could get tricky, especially if you don't have a third-party file manager software already installed on your phone.


The most obvious symptom of the trojan is that the typical programs on the phone won't work any more, and that their icons get replaced with a a picture of a skull. See below:



Thanks for the tip Marco

Wednesday, November 17, 2004

339.aspx

Free Visual Studio.NET Industry Partner DVD

Free Visual Stuido.NET Industry Partner Product DVD ships, for free, to U.S., Canada, Europe, Africa, and the Middle East



Order this free DVD and receive over 65 tools, components and languages from Visual Studio Industry Partners. These full version and evaluation products can help save you time and money building applications for Microsoft Windows, mobile devices, the Web, and Web services.


Via [jacobcy's WebLog

Monday, November 15, 2004

332.aspx

SonyEricsson on the future of the mobile web

SonyEricsson on the future of the mobile web. Some key points from the document:



  • In 2006 we expect most phones to have a mobile Web browser that is able to render almost any Web page on the Internet. WAP is history and, from a technology point of view, the mobile Web has converged with the de facto Internet standards.

  • The main new trends are


    • Music (over the air download and personal radio)

    • Imaging (Photo services and photo albums)

  • We expect more animations and multimedia being integrated into mobile Web portals, and the combination of all Web technologies (SVG, SMIL, XHTML, CSS, and ECMAScript) is the key to a standard solution for Web applications.

  • Push services are on the rise on the Internet, based on the de facto standard RSS. We believe that RSS has a great potential in mobile phones, as a technology to automatically provide updated content to users - accessing the Web without browsing.

Overall I agree and wish that all mobile devices would agree on xhtml with javascript as the standard. The phones -today- are too slow to display rich contents as they take 4-5 seconds too render a page after it has received all data. Add javascript and complex css formatting and you have time to go for a coffee. Navigating in old plain text wap mode is still a lot faster than navigating in xhtml mode.


Using RSS for push would be great as there are tons of feeds around. It would make it possible for anyone to create push services for mobile devices. Today push services are limited to a selected few that have the resources to send Wap Push or MMS. It only makes sense if the phone can see the post pointed to by the RSS though. It's possible too render a RSS summary on a device but most RSS feeds point to blogs that have "complex" layout that can't be rendered on a small device. They look ugly on a device like the Pocket PC that have an enormous screen compared to most mobile devices.


Phones also have to become a lot smarter and have more storage to figure out which posts it has seen already. Thinking about it, it could delegate this task to a feed server that keeps track of the items viewed by a particular SIM (assuming that SIM decides which posts are new, regardless of the device it is in). A bit like a Bloglines on steroids that provides one (or more) RSS feeds that give you new/unread items and keeps track of which items you read.

330.aspx

Asynchronous vs synchronous msxml 4 http call

One site I work on has been ported from ASP to ASP.NET. Many clients have a bookmark to the old ASP page which does not exist anymore. Redirection is possible but it is slow over mobile networks like GSM/GPRS/UTMS. To work around the problem I have implemented an ASP page that does a http GET request to the correct ASP.NET page on the localhost and sends the result back to the user.


This is the core:


    Public Sub getURL(ByVal sURL)
        '**
        'Purpose: Request the url and send the output to the end user
        Dim oRequest
        Dim sUserAgent
        Dim sAccept
        oRequest = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
 
        'prepare the request
        On Error Resume Next
        oRequest.open("GET", sURL, True)
 
        sUserAgent = Request.ServerVariables("HTTP_USER_AGENT")
        sAccept = Request.ServerVariables("HTTP_ACCEPT")
        If sUserAgent <> "" Then oRequest.setRequestHeader("User-Agent", sUserAgent)
        If sAccept <> "" Then oRequest.setRequestHeader("Accept", sAccept)
 
        'send and wait for reply
        oRequest.send()
        oRequest.waitForResponse(HTTP_REQUEST_TIMEOUT)
 
        'Check if ther is an error
        lRequestError = err.number
        On Error GoTo 0
        If lRequestError <> 0 Then handleError(ERROR_REQUEST_FAILED)
        If oRequest.readyState <> 4 Then  '4 => request complete
            oRequest.abort()
            handleError(ERROR_REQUEST_TIMEOUT) 'Does Response.End()
        End If
 
        'Send the response back to the user
        Response.ContentType = oRequest.getResponseHeader("Content-Type")
        Response.Expires = oRequest.getResponseHeader("Expires")
        Response.Write(oRequest.responseText)
        oRequest = Nothing
    End Sub

I have a strange problem in a Win2k3 environment with a lot of machines in NLB. When page1.asp calls page1.aspx I see the following time taken fields in the IIS log:
Page1.asp: 50 ms
Page1.aspx: 29995 ms


These results are impossible as page1.asp executes page1.aspx and waits for page1.aspx to complete output before it sends it to the client. So the call time of Page1.aspx must be lower than the call tome of Page1.asp. It seems like the aspx page waits for the asp page to close the connection somehow. The interesting thing is that it does not have this problem if it calls a remote server.


We found the fix but I haven't managed to epxlain to myself why it works. I guess the asynchronous thread causes problems, but why the heck does it only cause problems when going to localhost?


The fix is to make the request synchronously by changing the code like this:


        'prepare the request
        On Error Resume Next
        oRequest.open("GET", sURL, True False)
 
        sUserAgent = Request.ServerVariables("HTTP_USER_AGENT")
        sAccept = Request.ServerVariables("HTTP_ACCEPT")
        If sUserAgent <> "" Then oRequest.setRequestHeader("User-Agent", sUserAgent)
        If sAccept <> "" Then oRequest.setRequestHeader("Accept", sAccept)
 
        'send and wait for reply
        oRequest.send()
        oRequest.waitForResponse(HTTP_REQUEST_TIMEOUT)
 
        'Check if ther is an error
        lRequestError = err.number
        On Error GoTo 0
        If lRequestError <> 0 Then handleError(ERROR_REQUEST_FAILED)
        If oRequest.readyState <> 4 Then  '4 => request complete
            oRequest.abort()
            handleError(ERROR_REQUEST_TIMEOUT) 'Does Response.End()
        End If

Explanations are more than welcome.

Friday, November 12, 2004

322.aspx

CopySourceAsHTML version 1.2.1

Version 1.2.1 of CopySourceAsHTML has just been released. It fixes the problem I had in an earlier post, so I can cut and past directly in .text without having to go via the source view. Using the "Embed Styles" option the source code looks just great:


///
/// The main entry point for the application.
/// 
static void Main(string[] args)
{
    System.Console.WriteLine("Cool Or What?");
}

 


Now that Vodafonelive! has released I should have time to post some more source code :-)


Thanks for the tip Colin.

Thursday, November 11, 2004

318.aspx

#egilh project 12: UI hotkey checker

When: Mid 90s


What: Duplicate hotkey checker for menus and dialog boxes


While localizing software it's easy to make mistakes. I covered some of them in the Windows 95 post. A common issue in crowded menus and dialogs are duplicate hotkeys. Especially as the development team continues to change the menus and dialog boxes.


Finding them in testing is difficult for several reasons:



  • It is difficult to bring up all the possible dialog boxes. Some of them are only displayed with special hardware or in special conditions like 'low on disk space'.
  • You have to pay a lot of attention. It is hard to spot duplicate hot keys in a crowded dialog box. It is even harder to spot truncated text as labels may 'word wrap' or truncate at a natural point.

The good news was that all menus, dialogs and strings (selected by the developers) were stored in the 'resource section of  .exe, .dll, etc files. Visual Studio etc can open the files to view and edit the resources. Win32 introduced the resource APIs which made it possible to access the resources without having to parse the file structures documented in MSDN.


Using the new features of Win32 and some file format info I wrote a tool that extracted all the menus and dialog box and cycled through all the items in each file and generated a report of all the errors. The hotkey for each item (preceded by a &) was compared against all the other hotkeys in the same dialog box. Menus were a bit more complex as it also checked against the parent menu.


A completely automatic system like the one I implemented catches all the cases above, but it is not perfect as it is not able to catch bugs in menus/dialog boxes generated at runtime. My boss later wrote a window monitor that checked windows displayed on the screen at runtime.


Lessons learned:



  • Windows resource APIs and resource file formats

Wednesday, November 10, 2004

310.aspx

Vodafone live! is live!

We just released the new version of vodafone live! in Italy. Some external systems, like the games download, are not up and running yet but the portal works like a charm.


It looks a bit boring as a static image but is a real beauty with some the latest devices like the Samsung Z107, SonyEricsson Z1010, Nokia 6630 that support animated images.


Enjoy

Monday, November 8, 2004

307.aspx

Microsoft Windows Command Shell

Finally a real command shell under Windows. The new Microsoft Shell (MSH), code named Monad, is available as a beta distributed separately from Longhorn. It runs on XP, Win2k and Win2k3 with the latest Windows patches and the .NET 2.0 beta.


There are plenty of news, but the most important one is that the output of commands are objects, not text. This means that you can write 



get-process | where { $_.cpu -gt 10 }


to filter processes that takes more than 10% cpu without having to parse the output of the processes command. It also means that the script does not break if the output format change. The output can of course be serialized to xml and csv as well as plain text.


Plenty of cool new scripting stuff to have fun with, like the switch statement with regular expression support:



switch -regex ($var)
{ "word2"  {"Multi-match Exact " + $_ }
   "word.*" {"Multi-match Exact1 " + $_ }
   default  {"Multi-match Default " + $_; break}
 }


You can create variables of any .NET type linke or .NET/ActiveX objects:



$idx=[int]1
$books=[xml]"Davinci Code"
$dtStart=[System.DateTime]"2004/11/08"
$wsh = new-object -ActiveXObject "WScript.Shell"



I got a bit nostalgic trying some of the commands. Things are a lot more *nix like. Dir is an alias of get-childitem and returns the following



d---s   nov 08 16.25             Cookies
d-r--   nov 08 15.59             My Documents
d-r--   gen 21 19.02             Start Menu


Even the help is man-like: get-help dir



NAME
  get-childitem
 
SYNOPSIS
 
  get-childitem [[-Path] pathname] [-Recurse] [-Include includeFilter]
   [-Exclude excludeFilter] [-Filter filter] [-Force] [-Names]
  get-childitem [[-Path] pathname] -Relationship relationshipName [-Property p
  roperty]
     
 
SHORT DESCRIPTION
 
  Retrieves the child items of the specified location(s) in a drive.
  When -Relationship is specified, retrieves the available targets for the rel
  ationship.
..
 
EXAMPLES
  $ gch . * -exclude [a-e]*,*.dll -recurse -name
  Find all the names underneath the current location that don't start with the
   letters "a" through "e" or end with ".dll"


Jon's Radio has several examples of the cool stuff you can do with MSH. .


How to get it:



  • Go to http://beta.microsoft.com/
  • Log in with your passport account
  • Click the "If Microsoft issued you a guest account id"..
  • Enter the following Guest ID: mshPDC
  • Fill in the survey and wait


More info:



Via [Jon's Radio]

305.aspx

Microsoft ACT standalone installation

Microsoft ACT is great for stress testing web sites. The only "problem" is that you have to install Visual Studio .NET in order to use it. I use it frequently on my dev machine but some times it is useful have it on a remote machine for stress testing directly in a pre-production environment. The steps below shows how you can copy your local ACT installation to a standalone computer.


Pre-requisite: Internet Explorer 6.0


Steps by step instructions:



  • Copy the C:\Program Files\Microsoft ACT directory from you dev PC to the same directory on the remote machine

  • Create the Act.Reg and Register.cmd files below

  • Execute Register.cmd

  • Create a local user: ACTUser with the "User" rights

  • Set the Identify of the following COM objects to ACTUser (using dcomcnfg):


    • Application Center Test Broker

    • Application Center Test Controller

  • Give full control to ACTUser on the following WMI namespace using "Computer Management": Root/CIMV2/Application/MicrosoftACT


== Save as Register.cmd ==
c:
cd "C:\Program Files\Microsoft ACT"
regedit -s act.reg
for %%i in (*.dll) do regsvr32 /s %%i
ACTBroker.exe -regserver
actcontroller.exe -regserver
ACTRegMof.exe -i "C:\Program Files\Microsoft ACT\actnamespace.mof"
ACTRegMof.exe -i "C:\Program Files\Microsoft ACT\actbroker.mof"
ACTRegMof.exe -i "C:\Program Files\Microsoft ACT\actcontroller.mof"



== Save as Act.Reg ==
Windows Registry Editor Version 5.00


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ACT]
"AppPath"="C:\\Program Files\\Microsoft ACT\\"
"ProductCode"="{E05F0409-0E9A-48A1-AC04-E35E3033604A}"
"Feature"="AppCenter_Test_for_VS.NET"
"Version"="1.0.0536"


Disclaimer: Follow the instructions at your own risk and make sure you have a working backup!

Wednesday, November 3, 2004

301.aspx

Burying old code

It really bugs me when I find buried source code; large chunks of comments around old code that is not used anymore and will never be used again. It's just confusing. Delete the garbage and use a version control system to get the old code if you ever needed it again.


LexisNexis has a great idea for “taking care“ of old code; Programmers hold funerals for old code



DAYTON, Ohio - Among the tiny graves on Blocker Hill, the wind echoes with the tortured cries of computer programmers.  Beneath the eight grave markers, and perhaps in a rumored unmarked grave nearby, lie reams of paper printouts of code for software that has left this mortal operating system
The cemetery is a quirky tradition among the programmers at LexisNexis, which provides online legal and business information.  Rather than simply delete programs that are retired or replaced, they print them out for a proper send-off — not always with fond regards.

"Some things die gracefully and other things we've had to kill," Perseghetti said. He said workers had to "drive a stake" through the heart of a poorly performing program named CCI, which received an ignominious burial beneath an emblem of a pig.


I know several candidates that are in poor health and should be "taken care of" ASAP. I'll bring the garlic to make sure they never come back!

300.aspx

XMLSpy 2005

The XMLSpy 2005 family was released for download earlier this week. They support the XSLT 2.0, XPath 2.0 and XQuery drafts. Other new XMLSpy 2005 features are; automated function building, Eclipse integration, relational database content editing, and visual management of complex schemas:


Maybe I should convince my boss to buy it so I get an iPod:



While supplies last, you’ll get a free 20GB Apple iPod with every purchase of the Altova Enterprise XML Suite plus the one or two year Altova Support and Maintenance Package (SMP) from Altova or its subsidiaries. So, for example, if you purchase a five pack of licenses for your development team, you’ll receive five free iPods – one for each new user on your team! Certain export limitations and legal restrictions apply. See http://www.altova.com/ipod_promo.html for details.

299.aspx

Ingres r3 for Windows and Linux open source download


Ingres r3 was released as open source under the CA Trusted Open Source License (CATOSL) license in August.


The Linux and Windows versions of Ingres r3 are now available for download. Other platforms like 64 bit and Sun Solaris, HP/UX, IBM AIX will be available by early 2005.


The Ingres million dollar challenge for the best Ingres r3 toolkits is open until February 1st 2005.

298.aspx

Fast error code lookup

I usually use net helpmsg  to get quick info on error codes:



net helpmsg 5
Access is denied.


It works but not all the error codes are covered. It also wants the error message number in decimal whereas most programs return them as hex. The error code tool from Microsoft contains the error codes defined in the standard C include files (19871 return codes registered from 172 sources) and allows you to search by hex, decimal, name etc:



USAGE: err {value} [value] [value] ...
 where <value> must be of one of the following forms:
   1. decorated hex (0x54f)
   2. implicit hex  (54f)
   3. ambiguous     (1359)
   4. exact string  (=ERROR_INTERNAL_ERROR)
   5. substring     (:INTERNAL_ERROR)


Added to my toolkit!


Via [FurryGoat]

Friday, October 29, 2004

292.aspx

EXCEPTION_ACCESS_VIOLATION in SQL Server 2000 (SP3) on multiple CPU system

Now this is a strange one. The following stored procedure crashes the SQL worker process that is executing it:



CREATE PROCEDURE usp_UpdateDeviceEnabled
@idDettaglio int,
@sDevicelist text


AS


UPDATE CP_Valori
   set CP_Valori.sCPValore = @sDevicelist
   FROM         
      Colonne_Personalizzate INNER JOIN  CP_Valori ON Colonne_Personalizzate.idColonna = CP_Valori.idColonna INNER JOIN Dettaglio ON CP_Valori.idDettaglio = Dettaglio.idDettaglio
   WHERE    
     (CP_Valori.idDettaglio = @idDettaglio) AND (Colonne_Personalizzate.sType = 'CMB_DEVICE')


 


It bombs with the following errors:



Event Type: Error
Event Category: (2)
Event ID: 17052
Description:
Error: 0, Severity: 19, State: 0
SqlDumpExceptionHandler: Process 59 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.


Event Type: Error
Event Source: MSSQL$DB
Event Category: (2)
Event ID: 17052
Error: 0, Severity: 19, State: 0
language_exec: Process 59 generated an access violation. SQL Server is terminating this process.


It works on a single CPU system (Win2k3) but bombs on all multiple CPUs systems we tried it on (Win2k, Win2k3).  Tired most tricks in the book like recompiling the stored, dbcc, recreating the db on another machine etc without luck.


Most of the EXCEPTION_ACCESS_VIOLATION hits on Google refer to text fields, so we changed



@sDevicelist text


to



@sDevicelist varchar(8000)


And, believe it or not, the stored procedure doesn't bomb anymore.


It explains why we could not reproduce the problem by running the query in query analyzer, as it doesn't support local variables of type text. But it does not explain why it bombs in the first place. Suggestions?

Wednesday, October 27, 2004

281.aspx

The Return of Caller ID and other alternatives

Microsoft's original Caller ID for e-mail wasn't approved so they have merged their proposal with the Sender Policy Framework (SPF) written by Meng Weng Wong and Mark Lentczner. Have a look at the Sender ID Framework Executive Overview for a quick intro to what the Sender ID is.


My thoughts on it? SPAM sucks and there must be a way to fight it. Sender ID may be a step in the right direction, as it makes it easier to detect spam by automatic systems, but it does not prevent spam from being sent. It would be a lot better to kill the spam before it even reaches the internet. These days a lot of spam is sent by trojans and virus infected PCs with fast internet connections. There is, as far as I can see, no reason why any person or small company with a consumer broadband connection needs to send more than 1 mail every minute. Large companies are a different story but they don't have a consumer internet connection.


Internet Service Providers could block all outgoing traffic on port 25 and force clients to use their SMTP server with authentication to send mails. Mail clients are getting more secure so trojans/viruses don't use OLE Automation to send mails anymore but rely on their own spam sending SMTP client. SMTP authentication would fix the problem as they can't send mail directly to the internet anymore and they don't know the user name or password to use the ISPs SMTP server. Even if they magically found the username/password the damage would be limited as an infected host could only send 1 mail a minute and not several per second like they do now. Filtering is trivial as the ISP can work on a mail server level and not on a TCP/IP level.


I already use a similar setup on my LAN but I haven't gotten around to writing the outbound mail filter yet. You can reduce the chance of becoming a spam spewing bot by denying all outgoing connections to port 25 unless it is to your IPSs mail server


Other documents recently posted by Microsoft:


Sunday, October 24, 2004

275.aspx

Busy working on 3G and .NET

Wish I had more time to blog… I'm on a tight schedule working on compatibility and performance issues when delivering  contents to the latest and greatest UMTS/3G phones like SonyEricsson Z1010 and Samsung Z107 (wonder why all the latest models are all called Z something; Lack of fantasy? The End Of The English Alphabet?).


Only Coding & Music while I wait for the official release of project #100. More info after 4/11 when I should be able to say something without risking my job.

274.aspx

One the CD player: Kings of Convenience; Riot on an empty street

Bought the Riot on an empty street album by Kings of Convenience yesterday. Great music for coding sessions; easy listening and acoustic instruments.



One of the Amazon.com reviewers wrote "Okay if you are 30 something,". He must be a genius :-)

Friday, October 22, 2004

271.aspx

Visual Studio plugin to copy source code as html

A great little time saver; the CopySourceAsHtml plugin for Visual Studio makes it possible to copy html formatted source code to your blog without cutting and pasting it via Word.


Pasted via CopySourceAsHtml:




if (itWorks) 
{
Console.WriteLine("Cool Or What?");
}


Word is better from one point of view though: I can paste the code directly in the .Text edit window. With the plugin I have to go to the html source and paste the code in the correct place. OK for small posts like this but a bit of a pain in larger posts like the one on accessing the Pocket Outlook from .NET CF 1.0


Via [PowerToys]

Tuesday, October 19, 2004

264.aspx

Small, beautiful and fast: MenuetOS

Running a decent OS from a single floppy reminds of the first Linux builds I used (0.90-something). MenuetOS promises a lot more though with a full GUI as well:



MenuetOS is an Operating System for the PC written entirely in 32bit assembly language, and released under the GPL. It supports 32 bit x86 assembly programming since this allows for smaller, faster and less resource hungry applications to be created.


Menuet has no roots within unix or the posix standards, nor is it based on any particular operating system. The design goal has been to remove the extra layers between different parts of an OS, which normally complicates programming and create bugs.



Features
- Pre-emptive multitasking, multithreading, ring-3 protection
- Responsive GUI with resolutions up to 1280x1024, 16 million colours
- IDE: Editor/Macro Assembler for building kernel and applications
- TCP/IP stack with Loopback, PPP & Ethernet drivers
- Network applications include ftp/http/mp3/smtp servers,
- irc, http, nntp and tftp clients
- Free-form, skinnable application windows
- Hard real-time data fetch
- Fits uncompressed on a single floppy!


 

259.aspx

Apache and IIS security

Michael Howard, author of  Writing Secure Code  (2nd edition), compares IIS6 and Apache security stats


IIS 6 has been rock solid on the production systems where I use it and I have had no security problems. Got infected by Code Red on my Win2k dev machine a loooong time ago before I learned, the hard way, to harden my machines.

Monday, October 18, 2004

255.aspx

C# Edit & Continue support in Visual Studio 2005


It's official: Visual Studio 2005 will support Edit & Continue for C# What a great news on a Monday morning!



One of the top feedback requests from our customers is support for Edit & Continue (E&C) in C# in Visual Studio 2005. I am excited to announce that the C# team took your feedback to heart and has added support for E&C in Visual Studio 2005.


The Edit & Continue feature will be part of the next Visual Studio 2005 Technology Preview which will be released this week.

Thursday, October 14, 2004

249.aspx

CodeProject

CodeProject is a great resource. It has an active community with loads of sample code. I'm using the CxImage component a lot and it's a great example of the quality of the code on CodeProject.


It also has a weekly CodeProject newsletter


CodeProject member #47586  (of 1.437.688 last time I checked)

Wednesday, October 13, 2004

248.aspx

egilh project #11: Intranet Search

What: First some background info: I like to know how things work. I started picking apart broken kitchen appliances when I was a kid, trying to figure out what was wrong. I had a hard time buying spare parts though as repair centers wanted to do the job themselves to earn money. These days I check out How Stuff Works once in a while to learn something new.


It's the same interest in knowing what goes on behind the scenes that got me started programming as well. My neighbor convinced me to spend the few bucks I had earned picking strawberries during my summer vacation on a computer. I started using Lotus and WordPefect, constantly wondering how the stuff worked. I got my hands on Turbo Pascal and tought myself programing from the excellent online help an examples.


Fast Forward 10 years: AltaVista launched their search service,and I said to myself: how do they do that? So, during compiles and installations of Windows 95 I built a fully working crawler, indexer and web search server. I had limited resources but wanted good performance so I decided to use NTFS as a DB. FAT had a horrible linked list to find files but the "new" NTFS used b-trees to do very fast file name based lookups. Each page I crawled got a unique ID and was added to a fixed size record file with the title of the page, abstract, url, date etc. For each unique word in the crawled page I added the ID to a word file. Each word had it's own file in a directory system to avoid to many files in one directory. The ID of pages using the word 'Hello', for example, were saved in "\h\e\llo.dat". Pages that used Hi were stored in "\h\i.dat". One word queries were lighting fast as I just had to open a flat file with 32 bit IDs to get the list of pages containing that word. AND/OR queries were simple as well as I just had to join/intersect arrays. Then again, it didn’t have any of the fancy smancy Google relevance logic. It was a lot of fun to make and watch the progress of the crawler as it found it's way to the various internal web servers in Microsoft.


When: mid 90


Lessons learned:



  • The Microsoft web site is -huge-. I don't remember how, but my crawler ended up on the two internal mirrors of the public web site and it got "stuck" indexing the public web servers only. I can only imagine how large the site is now, 10 years later.

  • Sockets on Windows

  • Work smarter, not harder and you can accomplish incredible things

  • Parsing badly formed html pages

  • Html can be a pain to parse in C++. Long live Perl for parsing strange stuff and xpath for dealing with xml/xhtml

247.aspx

POOM sample: creating a new private task

Neither Outlook nor Pocket Outlook marks tasks as private. If you have a private PC it's not a problem but if you work with an Exchange server some companies leave your mailbox configure so -everyone- can see your "public" tasks. My tasks are private and they should stay so.


The following code sample uses the Pocket Outlook .NET Compact Framework class library to create a new task, set the due date to today, an mark it as private and display it so the user can enter subject and notes:


public enum Sensitivity


{                


      Normal = 0 ,


      Personal = 1,


      Private = 2,


      Confidential = 3


}



/// <summary>


/// Create a new task. The due date is set to Today


/// </summary>


/// <param name="sender"></param>


/// <param name="e"></param>


private void menuNew_Click(object sender, System.EventArgs e)


{


      PocketOutlook.Task task = (PocketOutlook.Task) _pocketOutlook.GetDefaultFolder(olFolderTasks).Items.Add();


      task.Sensitivity =  PocketOutlook.Sensitivity.Private;


      task.DueDate = System.DateTime.Today;


      task.Save();


      task.Display();


      //reloadTasks();             


}




 

Tuesday, October 12, 2004

240.aspx

Pocket Outlook: catching up with old tasks

I frequently have more than 20 tasks due each day. Stuff that must get done in high priority, some low priority reminders and blog notes. On the PC I use an Outlook macro but there is no macro language on the Pocket PC so I used the modified Pocket Outlook .NET CF class library to catch up with old tasks.


// In the class declaration


private PocketOutlook.Application _pocketOutlook;


...


 


// Startup code in the form Load() routine     


_pocketOutlook = new PocketOutlook.Application();                      


_pocketOutlook.Logon();


 



 


/// <summary>


/// Catch up with task that are due in the past


/// </summary>


/// <param name="sender"></param>


/// <param name="e"></param>


private void menuCatchUp_Click(object sender, System.EventArgs e)


{                


      // Get all tasks due before today


      PocketOutlook.ItemCollection tasks = _pocketOutlook.GetDefaultFolder(olFolderTasks).Items;


      PocketOutlook.ItemCollection oldTasks = tasks.Restrict("[DueDate] < \"" + System.DateTime.Today.ToString("dd/MM/yy")+ "\" and [Complete]=False");


     


      // The list auto-updates so we go a while loop always working on the first item instead of


      // using a for loop


      int updatedItems = 0;


      while (oldTasks.Count > 0)


      {


            updatedItems++;


            PocketOutlook.Task task = (PocketOutlook.Task) oldTasks.Item(1);  // 1 based                   


            task.DueDate = System.DateTime.Today.;               


            task.Save();


      }


      System.Windows.Forms.MessageBox.Show("Updated " + updatedItems + " tasks.");             


 


      // Reload the task list


     


}


 


 

239.aspx

Adding Google AdSense to a .TEXT blog

Had to look around the templates for a while but I found it in the end. Add the following in at the end of Skins\SkinName\Controls\CategoryList.ascx and insert the JavaScript script from Google. Works like a charm.


<ItemTemplate>


            <h3>Sponsored links</h3>


                  <ul>


                  <li>                         


                  PASTE SCRIPT HERE


                  </li>


                  </ul>


            </script>


</ItemTemplate>


 

Friday, October 8, 2004

234.aspx

Blog Schneier blogs

Bruce Schneier has started his own blog. I have been a faithful reader of the Crypto-gram newsletter / blog since I read the footnote in Cryptonomicon. He knows a lot about security and writes about it with a passion.


Via [Larry Osterman]

Thursday, October 7, 2004

228.aspx

egilh project #10: joke server

What: a small web based joke server. I saw all this programs popping up on the web and wanted to find out how I could implement my own. Collected some jokes I had in my inbox and saved them to a formatted text file (no xml yet). Wrote an indexer that generated a tiny lookup table so I didn't have to parse the entire file to pull out a joke. The CGI program in C pulled out a random joke each time a page was requested. Nothing fancy but it was fun to make and test.


Upgraded it later to use the predecessor to ISAPI when it was made available in a small web server that ran on Windows 95.


When: mid 90s


Lessons learned:



  • CGI is grand but ISAPI is way faster on Windows


 

Monday, October 4, 2004

223.aspx

Using the clipboard from .NET CF

I was about to implement my own clipboard classes for .NET CF when I found the Clipboard usage article.


It has complete source code that implements the two alternatives for working with the clipboard in .NET CF.


Alternative 1: use P/Invoke to call the following methods:
[DllImport("Coredll.dll")] private static extern bool OpenClipboard(IntPtr hWndNewOwner);
[DllImport("Coredll.dll")] private static extern bool CloseClipboard();
[DllImport("Coredll.dll")] private static extern bool EmptyClipboard();
[DllImport("Coredll.dll")] private static extern bool IsClipboardFormatAvailable(uint uFormat);
[DllImport("Coredll.dll")] private static extern IntPtr GetClipboardData(uint uFormat);
[DllImport("Coredll.dll")] private static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem);


Alternative 2: use the keyboard shortcuts
So far I manually work around the missing clipboard support in .NET CF by switching to the Keyboard instead of the "Block Recognizer" when I have to cut and paste. The Windows shortcuts for cut and paste works like a charm;
Ctrl + X: Cut
Ctrl + C: Copy
Ctrl + V: Paste


The textbox example adds a popup menu to a text field and simulates the user pressing keys buy using the keybd_event API.

Wednesday, September 29, 2004

213.aspx

egilh project #9: Windows 95

What: I started translating but passed through managing external translation vendors before I ended up doing what I liked best; technical specialist. The way we translated Windows 95 was drastically different from the previous translation work; instead of editing include and resource files, we modified the resource sections in the final English version (i.e. directly in the .dll or .exe). Translating the resource files gave fast turn-around as the change was visible immediately. It was also a mess some times as some times the word "Desktop" should be translated, other times it’s the internal name in Windows for the desktop and everything boke if you translated it.


The tools for translating were, as usual, pretty bad so I spent some time writing tools that automated the process (more posts later on these later).


When: mid 90s :-)


Lessons learned:



  • Installing and using Windows 95 "blindfolded". Seeing the characters doesn't really make much of a difference when you try to troubleshoot a problem in Greek, Russian and Turkish….

  • Patience. I did a lot, but a lot, of builds of Windows 95. It came in tons of flavors; 5 1/4 floppies, 3 1/2 floppies (small and large build), CDs, ... Each build took the best part of the day as the new .CAB building tool optimized the organization of the files etc. In the few weeks after the US team RTMed I worked nights (and days) to build the most critical languages (French/Spanish)

  • Work smarter not harder:  You can do a lot of stuff if you mange your "dead time" well. The next bunch of projects are internal projects I worked on while installing/building etc

  • Working 2 years  on a "never ending" project is not for me. I hope it is better working in the Redmond dev team or I feel really sorry for the Longhorn developers

  • Brad Silverberg sounds a lot like "Brat Silverberg" (a -very- good friend almost made the mistake to his face)

  • Microsoft really knows how to throw a release party. I had the pleasure of attending both the internal one and the public one with Jay Leno.

  • The Windows 95 T-shirts are incredibly strong. I still have, and use, a few of them while working on the house/garden.

  • Writing software that can be translated/localized. The string "%s printing on %s" should have been translated to "Printing %s on %s" in some languages but it was impossible in Windows 95 (which explains the funny wording in some localized versions). This is one of the things they got right in .NET. Format strings now use positionsl, so "%1 printing  %2" can -finally- be translated to "Printing %2 on %1" without changing the software