Tuesday, March 28, 2006

The best definition of software architecture I've heard

My friend and fellow Architect MVP, Eric Newcomer mentioned in a blog post something I said when we were having dinner last week in SF and it ended up in SOA Web Services Journal. I'm glad all my ranting pays off once in a while ;-).

I'm speaking at DevTeach 2006

I'm speaking again this year at DevTeach 2006 in Montreal May 8th-12th.

I'm doing three sessions this year, one called "VS2005 Data Sources and Data Binding" and a two part session on "Designing Applications for Multiple Smart Client UIs". That one also demonstrates a server architecture that supports windows clients as well as mobile devices against the same centralized data. We'll also discuss occasionally connected scenarios and architecture options we have today and in the future. You can see all the speakers and sessions listed here. Hope you can make it!

Sunday, March 26, 2006

Allowing impersonated accounts to write to your custom event log

Here's a little tid-bit of information that I've had laying around for a while that I'd thought I'd share. .NET lets us easily create our own custom event logs with:
EventLog.CreateEventSource(source, logname)
As long as your an administrator running this code, it will create a custom event log. On a Windows 2003 machine only interactive users, services, batch accounts, admins, and server operators can read and write to this log. If you have components impersonating a least privileged user account then you will not be able to write to your event log. There's a couple ways I know of that you can do to fix this. You can allow any authenticated user write access to your log or you can allow the specific user SID write access. Open up the registry editor to your event log CustomSD key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Eventlog\MyLogName\CustomSD
To allow all authenticated users write access add the following security permission:
(A;;0x0002;;;AU)
To allow a specific user write access you would specify their SID:
(A;;0x0002;;;SID-OF-USER-ACCOUNT)
For more information see Development Impacts of Security Changes in Windows Server 2003

Friday, March 10, 2006

Connecting to SQL-Server Express on a remote XP SP2 machine

If you are experiencing problems connecting to a SQL-Server Express database on an XP SP2 remote box via Remote Desktop - there's a HotFix here you can get to resolve the issue.

Monday, March 06, 2006

New text rendering in .NET 2.0 WinForms

Winforms 2.0 added support for drawing GDI text with the new TextRenderer class available in the Systems.Windows.Forms namespace. Using this class to draw strings is now the preferred way instead of using the previous Graphics.DrawString method. So not to break previous WinForms applications, there is a new property on controls called UseCompatibleTextRendering, and if set to True this will draw text as it used to in 1.1.

On application startup, you can globally set this on all controls with:
Application.SetCompatibleTextRenderingDefault(False)
This draws all the labels in the system much clearer than previous versions especially when using the Tahoma 8.25pt font. When using this font at design time and dragging fields from your datasources window, the labels will line up using the new 2.0 behavior, but if you forget to set this at runtime using the above code, you may notice your labels not lining up properly.

If drawing strings manually, like from paint handlers on controls, you'll want to use the new TextRenderer.

So instead of:
Graphics.DrawString(someText, Me.Font, New SolidBrush(Me.ForeColor), rect)
Use this code instead:
TextRenderer.DrawText(Graphics, someText, Me.Font, rect, Me.ForeColor, TextFormatFlags.Left)