We haven’t needed to implement a Windows Service in a while, but certainly have experienced the pain of debugging them when run by Service Control Manager (SCM). Here are a couple of links to good tools and discussion on the topic:
Run Windows Service as a Console Program by Einar Egilsson provides a good example of how to debug your service easily as a console app. It also includes some good discussion of single- and multi-service hosting services, various ways to end or break out of the service process when running as console app, etc.
Windows Service Helper on CodePlex is a SCM replacement which provides for F5 debugging from Visual Studio. The UI it provides gives you the SCM-esque start, stop, pause capabilities to facilitate debugging the associated functionality in your service.
Hopefully these may be useful to you, but if nothing else, this will be a good reminder for the next time we do a Windows Service.
We were having some really strange behavior with the AjaxControlToolkit’s ModalPopupExtender – everything was fine on one page, but not on another. One major purpose of using MPE was to wrap a common control. So, as you can imagine, we got pretty frustrated. If two pages can’t achieve consistent results with shared components, development and maintenance cost projections are less predictable (although “lower cost” goes right out the window).
After quite a bit of painstakingly slow walk-throughs of the .aspx pages, we finally discovered that one of the pages had the MPE declaration within an UpdatePanel. Since this was the misbehaving page, we simply moved the MPE outside the UpdatePanel and voilà! – it misbehaved no more.
We didn’t really dig into why our MPE inside a UpdatePanel behaved as it did – we had already burned A LOT of time on the problem and needed to push on to our deadline. One of the devs found that this post seemed to be on track, so we’ll re-visit it if we find ourselves in need of making an MPE work within a UpdatePanel.
It may be worthwhile to mention that using the debugger didn’t help a bit in this case. We spent untold hours making a little change here, checking the behavior, adding some extra debug code there, checking the behavior, etc. Painfully frustrating. But in the end it came down to hawkish eyeballing of the .aspx files.
Windows Azure SDK 1.3 (a.k.a., November release) has just been released. You can download just the SDK, but if you’re using Visual Studio, use the Windows Azure Tools for Visual Studio instead. This package, VSCloudService.exe, includes the SDK package.
The major features / benefits of this release include:
Management Portal – the new Silverlight-based portal may be the most significant improvement of this release. Managing Roles, Storage, Service Bus, Access Control, etc. are so much easier to access, and the portal’s performance improvements make a substantial impact on management tasks.
Full IIS – Finally! Each Web Role can host multiple sites – web apps, services. Additionally, developers can now install IIS modules as well (some apps haven’t been migrated due to dependence on 3rd party or custom modules)
Remote Desktop – I’ve been looking forward to this for a while! Being able to connect to Azure Roles and VMs via RDP is going to make a huge difference in so many ways – configuration, deployment, debugging, etc.
Windows Server 2008 R2 – Azure Roles and VMs can now be based on R2 which brings in IIS 7.5, ability to restrict what apps can run via AppLocker, PowerShell 2.0 for better administration and automation.
Elevated Role Privileges – I’m not so sure this is a really good idea, but it’s in now. Azure Roles allow running with administrator privileges (sounds like “running with scissors”). I can imaging some scenarios in which a Worker Role does a bit of admin level work, or a Web Role hosting a custom administrative portal. But, in general, devs need to be very careful with this “feature.”
Multiple Admins – Multiple Live IDs can be assigned admin privileges in an Azure account. This provides better traceability when you’re doing around-the-clock administration. But it may also introduce risk of “stepping on each other’s toes” problems.
Also in this round of updates are a couple of betas and CTP.
Extra Small Instance – in BETA – at just 5 cents per compute hour, the Extra Small Instance is less than half the cost of the Small Instance (12 cents per compute hour). At the time of this writing, the Extra Small Instance is comprised of 1.0 GHz CPU, 768 MB RAM, 20 GB local storage and “low” I/O Performance.
Virtual Machine Role – in BETA – Now you can define and manage your own virtual machine. Based on the (very) little info I have right now, the VM is based on a differencing disk over a Windows 2008 Server R2 VM. That limits the options of what to run in the VM. IMO, this is the last check-box for Azure qualifying as Infrastructure as a Service (IaaS).
Azure Connect – in CTP – Connect provides the ability to create a virtual network between multiple devices. For example, if companies A & B want two of their systems to communicate with each other, those systems connect to Azure, establish the private network, and then communicate directly between A & B. I really want to test this one out!
If you are working with a .NET-based Windows service and have trouble uninstalling it, the problem may be due to allowing it to interact with the desktop. I used the Services admin tool to change the service’s security context to Local System. When I made that change, I also enabled “Allow service to interact with desktop.” Later, after making some code changes, uninstalling the service failed. To uninstall, I used
InstallUtil.exe /u <service>.exe
but the uninstall failed saying that the service is “marked for deletion.” After trawling around a bit, I found this message in the event log:
“The [service name] service is marked as an interactive service. However, the system is configured to not allow interactive services. This service may not function properly.”
So, Windows Server 2008 R2’s local policy must default to disallow services to operate interactively. I disabled “Allow service to interact…” and uninstall is working again.
BTW, allowing a service to operation interactively is not a good idea in the first place. I was just going to use it for some output / debugging during development.
I tinkered with the first public beta of Microsoft’s new Lightswitch application development tool. Here’s a few initial thoughts:
Lightswitch makes it very easy to access data in pretty rich ways. Business people who are not developers will be able to unlock corporate data in ways that would typically require a developer or significant knowledge of querying tools, etc.
Lightswitch is easy, approachable, but there’s still some learning curve involved. Layout Items such as Vertical Stack, Horizontal Stack, Text and Picture, and so on provide rich user interface capabilities, but how long will it take users to learn how to use them properly.
Data access is very easy — maybe too easy. Just point Lightswitch to an existing data store and go!
Relationships to data are automatic or easy to assign. The features around these relations are very good — Master-Detail screens are super easy.
There’s no hard deployment requirement for Lightswitch apps. Yes, it requires Silverlight, etc., but you don’t have to deliver it into an IIS farm, etc.
OOPS! Businesses must realize that all previous points add up to the potential for major train wrecks with data. For example, data relationship features make it easy to create Master-Detail screens, but cascading deletes are just as easy.
Businesses should take great care to ensure that all Lightswitch application development runs against TEST data. Far too many companies ignore or skip this Best Practice, but they may suffer seriously if they aren’t careful.
Protect data at the database; not in the app. Again, this is a Best Practice for software design, but I wouldn’t expect business people to be in tune with it. DBA’s or data owners must protect production data and provide matching test databases (identical schema, data domains, security, etc.)
Don’t prototype and expand. People will be tempted to take a Lightswitch application’s generated code, turn it into a full-fledged Silverlight project and then build from there. Don’t! Is it possible? Probably, but it’s also possible to climb stairs to the top of the Empire State Building. I suspect future versions of Lightswitch will reduce this gap (a la creating OCX’s with VB back in the day)
Lastly, I did run into several bugs — not unexpected in an early beta. One example the product team may be interested in has to do with changing screen layout in non-debug mode (Ctrl-F5 from VS2010) results in
Error: The last change wasn’t successfully persisted. Please shut down the running application. Error: Change cannot be persisted because KittyHawk is not running under debug mode.