May 2006 - Posts
Recently I've been working on the installation routine for the next release of our Cognitio Search product. I've been working on some code to configure the Database Mail features of Sql Server 2005 from managed code using the classes in the Microsoft.SqlServer.Management.Smo.Mail namespace. For a while this completely fooled me. Once I had a Server object instantiated for the Sql Server I'm configuring it was easy to retrieve the SqlMail object and create a new MailAccount instance. The problem was that the MailAccount instance didn't refer to the correct SMTP server but always referred to the (local) server on which the Sql Server instance is installed. In my case the SMTP server used to send email is not on the local server but is located elsewhere in the network so I figured I needed to change the name of the MailServer instance, but whenever I tried this using hte Name property (which apparently has a mutator) I kept getting a FailedOperationException. Id noticed that the dbo.sysmail_add_account_sp stored procedure allows you to specify the SMTP server name when creating an account, but the managed MailAccount class doesn't seem to provide the same facility.
After spending the best part of an afternoon reading the documentation I finally figured out the answer. When a new MailAccount instance is created a default MailServer instance is created and added to the MailServers collection of the MailAccount instance. The MailServer class has a Rename method which allows you to change the name of the MailServer to the name of the SMTP server you want to use, but it's not actually possible to set this directly when you create the MailAccount. Quite why you can't construct an instance of the MailServer class and add it to the MailAccount.MailServers collection is beyond me?
I have to say that the SMO documentation in Sql Server 2005 Books Online / MSDN Library really sucks. I've done quite a bit of development with SMO now and it always seems to have a really convoluted way of doing what you want to do. I know there's a tension between the object-oriented and relational/database world, but SMO does really feel like OO bent as much as possible to make it familiar to the (SQL) database developer's expectationsm and this isn't helped by the awful (lack of) documentation. As far as examples of configuring Database Mail goes, there's a single VB sample that illustrates creating a MailAccount by calling the MailAccount constructor. Good ol' Google isn't much help either as there appears to be very little documentation out there other than what's in MSDN Library (or if there is, my afternoon of Googling didn't find it)
Anyhow, I finally got it working so all I need to do know is figure out how to programmatically enable Database Mail on the Sql Server instance that our product is being installed on. By default Database Mail is not enabled and has to turned on using the Sql Server Surface Area Configuration Tool or the wizard in Sql Server Mangement Studio. That's not a painless installation experience for my users so I want something a bit more automatic. I'm assuming it's possible because Team Foundation Server seems to automatically enable sending mail alerts when it installs and I figured it probably uses Database Mail. Stupid me, having checked it again it appears that Team Foundation Server doesn't use Database Mail at all. Oh well, I'll keep looking for a way...
-------
David
del.ico.us |
Digg It |
Technorati |
StumbleUpon |
Furl |
reddit
I bought a bit of GPS navigation software recently for my Windows Mobile 5 Pocket PC. I spent a while looking at the various products out there and finally decided that I liked the interface of CoPilot best, so I went ahead and bought it and on the whole I'm very satisfied with the purchase. It does an excellent job of navigation and its route finding is very good.
Not everything is rosy in the CoPilot garden though, and I am having a few niggles with it. It came supplied on an SD card from which I installed it to the device and it worked first time, but didn't have any choice of voices for the spoken navigation commands like the literature said. I eventually figured out I need to copy the contents of the Speech/UK English directory on the installation card to the installation directory on the device and then it worked fine. Quite why it doesn't install these wave files when it installs is a mystery.
Installation itself isn't always straightforward. If you're installing this product I'd advise you to have your device running on mains power when you do the install, or modify the power settings to change the auto-power down time to something longer than it takes to do the install (e.g. 10 mins). If you don't do one of these then your device will power off midway through the install; when you power it back on it will carry on installing but will have missed some part of the install out as when it restarts the device at the end of the install, there's no CoPilot icon and it doesn't appear in the list of installed programs. Running the install again fixes the problem.
There are some other quirks too. On my device CoPilot refuses to run if ActiveSync is running when CoPilot attempts to start. It never bombs out with an error message, it just doesn't start, so I always have to remember to go the running programs list and shut down ActiveSync if it's running. I'm not sure why it doesn't like running alongside ActiveSync - there's more free memory than CoPilot says it needs, so I guess these two are just not happy sharing a CPU. If anyone's found a fix for this I'd be interested to hear about it. The other things causing me grief is the download fo map data from the PC to the device.
Apparently you can download data files directly to a memory card in the Pocket PC if the Pocket PC is ActiveSync'd to the machine running the CoPilot desktop client. My Pocket PC has a 1GB SD card installed with 900MB of free space and the desktop client sees this as a valid destination for data files I want to download. However every time I try to download the UK map (~117MB) it tells me that there's only 79MB of free space in which to download the map. I've no idea where it gets this figure from, as there's way more storage than that free on the card, and significantly less than that free in the memory of my Pocket PC. I borrowed a card reader to try downloading directly to the SD card from the PC and that works fine; the desktop client correctly detects the 900MB of free space on the SD card and everything works nicely. I'm guessing this is a bug with the ActiveSync/RAPI integration from the CoPilot desktop client but it's rather annoying as I've now had to go out and buy a memory card reader for my PC just so I can copy data files. Again, if anyone knows a workaround I'd be interested to hear it, though it's a little late now as I've already paid out for the card reader.
In the past few weeks I've seen quite a few bits of software that do 95% of what they claim to do and the missing/not fully working 5% is not in some little-used part of the product but in some of the core advertised functionality. May be this is a reflection of economic pressures causing developers to cut more corners in responding to a business need to get their products shipped quicker. Whatever is causing it, it unfortunately seems to be on the increase.
-------
David
del.ico.us |
Digg It |
Technorati |
StumbleUpon |
Furl |
reddit
I came across this post about dealing with unhandled ASP .NET exceptions on the blog of one of the Microsoft escalation engineers. It also mentions a Knowledge Base article on creating a custom HTTPHandler module to trap unhandled exceptions that may occur during the execution of an ASP .NET application.
When we were writing the current version of Cognitio Search we put a lot of effort into adding exception handlers for a wide range of exceptions which might be caused by expected unexpected (if that makes sense) events. We also wrote a component which traps these exceptions and uses a custom work item type to log them as an error in our Team Foundation Server with full stack trace and information on the components that caused the problem. So if an exceptional but anticipated event occurs, such as the server losing contact with the Domain Controller for some reason, we will be notified of this failure via the Team Foundation Server and it will also be recorded in the event logs.
But what happens if the sky really starts falling down around our head and something completely unexpected happens? (e.g. a sudden and catastrophic failure of the disk that holds the files of the ASP .NET web site). In this event ASP .NET will generate an exception that we currently have no mechanism to catch. Sure, an ASP .NET failure event will appear in the system event logs, but we don't get the notification or any details of the error back in our Team Foundation Server.
Having looked at this post and the KB info on creating a custom HTTPHandler for unhandled exceptions, I think I may adapt this technique and introduce it into the next release of Cognitio Search so that any truly unexpected exceptions can be caught, diagnostic information captured and inserted into our Team Foundation work item store. This will certainly help us give better support to Cognitio users and help us get a deeper understanding of any issues that we hadn't anticipated.
When I get round to it I'll post an article showing how we created our TFS remote bug logger using ASP .NET web services and I'll also post any modifications I make to allow it to deal with the totally unexpected ASP .NET exceptions.
------
David
del.ico.us |
Digg It |
Technorati |
StumbleUpon |
Furl |
reddit