Ahmed Salijee

Ahmed Salijee

Learnings from Win7 AppCompat Labs

Last week, we hosted a series of Windows 7 AppCompat Lab for ISVs. I attended along with a consultant. Below are some high level learnings of where apps had issues.

  1. Writing to a “secure” directory – mainly Program Files. Many companies had apps where they wrote data or some config information into some kind of INI,XML or SQL Database. Today, if you do not have an application manifest, Windows will virtualize these calls and create a copy of these files in a VirtualStore. You can browse through something like C:\Users\ahmeds\AppData\Local\VirtualStore to see these files. If you do have a manifest, virtualization is turned off – and if you run your name normally, you will likely get a permission denied error.
    • Depending on the scenario we would recommend putting this into ProgramData (if the data is shared) or the user Folder (if it is per user)
  2. Auto Updates of App. I was quite interested to see the number of companies who have built auto updating of apps. All of them done in different ways. In many ways this is the same issue as (1) except here you are writing dlls/code rather than data. Some ISVs changed the ACLs so that normal users had write access to these folders. In general you might want to make sure that the updater sits in a different EXE – and you mark this EXE as requires admin. Requires admin in some companies will actually require an admin to type in credentials.
  3. Registry. Did not see a lot of this but in some cases applications were writing data to the HKEY LOCAL MACHINE
  4. 16 bit. This was interesting. Everyone’s apps ran on a 64 bit machine (where 16 bit code is not allowed) yet it seemed like some were still shipping some 16 bit DLLs.
  5. High DPI. This is something most apps will have an issue with. Even many MS apps have some issues. As screen resolutions get higher, people will use DPI to make the text bigger. This can cause problems with text,controls etc getting cut off or not being properly visible.

The first 3 are all as a result of UAC.

At the same time, we also played with the logo test. Most common issues here

  1. Not providing all the information (like VersionNumber, Publisher etc) when installing the app
  2. Not signing the code (with Authenticode signature)
  3. Not having a manifest

All three of the above are “easy” to fix but the last one does have ramifications, as indicated in the point (1) in the first part.

Finally, the tools to help with the analysis is the “Standard User Analyzer” and the Logo test tools.

What happened 10 years ago, today?

I was listening to the radio this morning, and the sports guy brought up a painful memory. He wanted to know what what happened on this day – 10 years ago.

Well on the same day that we are about to meet Pakistan in the T20 Semis. 10 years ago was the day when we drew (yes we lost the game we actually drew) the game against Australia in the semis on the World Cup.

Will fate repeat itself. Let’s hope not!. Run, Donald, Run!

MSTest.exe not found when running tests in Team Build 2010 on 64 bit machine

I was playing around a bit with Team Build 2010 – and wanted to check out the new gated checkin feature. One of the common things I do, is to setup a Windows app, a class lib and a test project. I then add this to source control and create the build.

I was able to setup the build without too much hassles but then started to have some issues when I ran the build. The first issue was an error

“The MSTestActivity was invoked without a value for either TestMetadata or TestContainers”

For this error I just created a test list and put my tests in there. This made this error go away.  I found this resolution here

Once this error went away I then got a second error

“File not found: MSTest.exe”

This was very frustrating. The test run fine in Visual Studio (VS is 32 bit) but failed in Team Build (running on a 64 bit machine). After checking with our internal guys, I got this workaround

The Team Build MSTest activity looks in the wrong registry hive to locate the installed locations of the various versions of mstest.exe, and therefore fails to locate them appropriately.  The workaround here is to copy the InstallDir value in the registry from HKLM\Software\Wow6432Node\Microsoft\VisualStudio\10.0 to HKLM\Software\Microsoft\VisualStudio\10.0.

I tried this and my tests ran fine.

Virtual (not supported!) Adventures

Windows 7 and Windows Server 2008 R2 ships with a really cool feature. This is the ability to boot from VHD. There are a couple of different ways of doing this. The one would be create the initial VHD and then install the OS and whatever else you want. I did not really pursue this route.

What I wanted was a backup of my physical drive. I had just installed WS08 R2 along with SQL, Sharepoint, TFS2010 and VSTS2010 – and wanted to back this up.  It turns out that using the Backup features of Windows you can create a VHD image. This was news to me. I gave this a try and voila – a nice VHD created for me. I just imaged drive C. I put the backup VHD on an external USB drive.

The next step was to enable the “boot from VHD”. This was not difficult. You start off a command prompt in admin mode. Then run this

bcdedit /copy {current} /d “Boot_From_VHD”

Copy the CSLID from above and then run (you replace {CLSID} with the CLSID from above)

bcdedit /set {CLSID} device vhd=[C:]\vhdname.vhd

bcdedit /set {CLSID} osdevice vhd=[C:]\vhdname.vhd

bcdedit /set {CLSID} detecthal on 

IMPORTANT: The square brackets around the drive letter are required. It is fine to have the vhd in a subfolder.

I then rebooted and the first error it gave him had to do with the lack of disk space. Now this can be confusing. I have a 180GB HDD. My C drive was set to 95GB. I then copied the VPC to the C drive. This VHD was 35GB. So the VHD was looking for this partition of 95GB and could not find it. Workaround was easy. I extended the C volume to make use of the full 180GB and the VHD booted just fine.

TIP – Make your initial C drive volume as small as possible if you are following my route.

Then came the grief. The VHD booted fine. What is suppose to happen when you boot from VHD is the VHD drive is suppose to be assigned C and your host drive (your physical drive) should get assigned D. This makes full sense.

However in my case the VHD was getting assigned drive D and the physical drive was staying at C. This caused all havoc. The registry etc was still pointing to the C drive, and as my physical and virtual drives were similar to each other, they started to affect each other. It actually took me quite awhile to determine that the wrong drive letters were being assigned. I only caught on when I had issues in my virtual drive, made changes to try and fix it. Then booted in my physical drive – only to notice that things had changed. Only then did I investigate and realize my error.

I emailed an internal alias and got told that my method for creating the virtual drive and booting off it is not supported. The backup feature of creating a VHD is intended for that – backup!.

However, I got another tip which was

While booted into the VHD, try renaming HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices\DosDevices\C: to HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices\DosDevices\X: (or some other available drive letter) and reboot

I did this. I renamed c: to D: and D to C. Rebooted and Voila. A nice backup.

One important thing to note is that everything is on the same machine. If I took this VHD and tried to run it on a different set of hardware I would probably need to run a repair of the install. Alternatively you could look at things like sysprep when creating the image.

Now I have a little backup on my physical drive. The performance difference when booting from VHD is quite small.

Windows 7 for Developers training

We are delivering some Windows 7 training next week. 2 days focused on new features and 1 day on application compatibility. It seems like we might have 3 or 4 places available. If you are interested, please let me know. Contact me via the blog.

Are you an ISV interested in Windows 7?

If you are an

1) ISV, i.e someone who builds a product and then sells it many different customers AND

2) you have a reasonable installed base who are already running a Windows app OR for whom you intend to build a Windows based app AND

3) you are keen on the new Win7 features OR appcompat on Win7 then

contact me via this blog – and we can take the conversation further.

Creating a scheduled task in Vista

I was helping someone this week with an issue on creating a scheduled task in Vista. They were using some managed wrapper, which you would need under XP. While doing some research, I learned that is a COM based component that you can use in Vista (or Windows Server 2008).

 

From your app you just a reference to taskschd.dll – which is in the windows\system32 directory. You can then write code similar to below. This is in VB.

Imports TaskScheduler

Public Class Form1

    Const TASK_TRIGGER_DAILY = 2

    Const TASK_ACTION_EXEC = 0

    Const TASK_CREATE = 2

 

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim objService As New TaskScheduler.TaskScheduler()

        objService.Connect()

        Dim objFolder As TaskScheduler.ITaskFolder = objService.GetFolder("\")

 

        Dim objTaskDefinition As TaskScheduler.ITaskDefinition = objService.NewTask(0)

 

        Dim colTasks As TaskScheduler.ITriggerCollection = objTaskDefinition.Triggers

 

 

        Dim objTrigger As TaskScheduler.ITrigger = colTasks.Create(TASK_TRIGGER_DAILY)

      

        objTrigger.StartBoundary = "2008-06-27T08:00:00-00:00"

 

 

        Dim colActions As TaskScheduler.IActionCollection = objTaskDefinition.Actions

 

        Dim objAction As TaskScheduler.IExecAction = colActions.Create(TASK_ACTION_EXEC)

        objAction.ID = "Daily Task Test"

        objAction.Path = "C:\Windows\System32\notepad.exe"

 

      

        Dim objInfo As TaskScheduler.IRegistrationInfo = objTaskDefinition.RegistrationInfo

 

        objInfo.Author = "Administrator"

        objInfo.Description = "Test task ."

 

        Dim objSettings As TaskScheduler.ITaskSettings = objTaskDefinition.Settings

        objSettings.Enabled = True

        objSettings.Hidden = False

 

        objFolder.RegisterTaskDefinition(Path:="Test Daily Trigger", pDefinition:=objTaskDefinition, flags:=TASK_CREATE, UserId:="", password:="", LogonType:=0)

 

 

 

    End Sub

End Class

Source code from Devdays Silverlight session

I received a few requests at Devdays, and after Devdays, for the sample app that I built. I was hosting a course the week after, and then went on leave. Hence the delays. I also wanted to script the creation of the database.

I have packaged it and uploaded it. You can download from here.

Be sure to check the readme file. Maybe I should have called it dontreadme_veryconfidential.txt!.

One thing I forgot to mention in the readme is to download the Silverlight Toolkit which you can get from here

BizSpark!/ISV Breakfast

BizSpark is a cool new program we have for startups. For virtually nothing, you can get tons of software for development AND deployment. The launch locally is happening soon along with some other information on programs you can leverage, as well opportunities that ISVs can take advantage of.

 

Event details

Audience: TDM for software dev companies

JHB: 24 Feb (08:00 to 10:30) @ La Toscana, Monte Casino – Registration: Click here to register

CT: 25 Feb (08:00 to 10:30) @ Atlantic 1, Lagoon Beach Hotel, Lagoon Gate Drive, Milnerton – Registration: Click here to register

DBN: 3 Mar (08:00 to 10:30) @ Delano Room, SunCoast Conference Centre, SunCoast Boulevard, North Beach – Registration: Click here to register

 

Link for info on BizSpark: www.microsoft.com/BizSpark

Devdays – it’s back and at the movies

Register now.

Durban: 10 Mar

http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032401921&Culture=en-ZA

 

Cape Town: 17 Mar

 http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032401716&Culture=en-ZA

 

Johannesburg: 26 Mar

http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032401714&Culture=en-ZA

Note – You will have to pay for parking. For a full day event, it should hopefully not be a big deal!

As you can imagine, I have quite busy getting ready for the event. I am presenting just one breakout but I am responsible for the opening and closing keynotes.

Dell XT2, Windows 7 and MultiTouch

I got a nice Dell XT2 tablet on loan from the local Dell guys. I really like it. The reason I got it was a potential demo on Multi Touch running in Windows 7. When I got the machine it had Vista I installed.

With Vista, it does have some third party software installed to enable the touch functionality, since touch is not built with Vista. I am not obviously referring to touch with the stylus.

I quickly upgraded to Windows 7, and disabled the app that enabled touch with Vista.  The basic touch functionality worked just fine, as Win7 as the touch functionality built in. After looking at some other demos on touch, I found an issue. I tried to use 2 fingers to zoom in and out in Internet Explorer – no luck. I called Eben to try but he had no luck either.

After some searching I finally found http://www.n-trig.com/content.aspx?Page=Multi_touch. I downloaded the DuoSense multi-touch beta package for the XT2 from this page. After a quick installation where it seemed like the firmware was getting updated , and then a reboot- I had Multitouch working. Cool.

ISV Strategy – a couple of examples

In an earlier post I blogged a little about some of the areas you need to think about when defining an ISV Strategy. I thought is might be useful to have some examples – purely fictional. These are not perfect examples but might help

Example 1: Northwind

Northwind is an ISV in the property management space. Today they sell a solution that is aimed largely at the corporate space. The technical solution is a .NET Framework 1.1 solution that uses .NET Remoting to connect to a middle tier. They use SQL Server 2005 as the database backend. The user interface is a Windows Forms based application.

The high level strategy for the next few years has been defined as follows:

The business strategy: Going forward Northwind have the following focus areas

  1. Expand the solution offering so that it can be sold to anyone doing any kind of property management. For example, they intend to sell solutions for companies that manage residential properties as well.
  2. Expand the business. Northwind would like to start selling in other markets, especially those that are English speaking. The strategy would be to find partners in those markets to resell rather than opening an office.
  3. Hosted Solutions and the Web. Northwind would like to provide a solution that can be used off premise and one that does not require client software to be installed. It is however, not abandoning rich client scenarios. In fact it is looking to integrate with Microsoft Outlook for many core scenarios.

The technical strategy: Northwind will focus on the following areas:

  1. As many customers would like to configure many processes, Northwind will be evaluating Workflow Foundation to provide support for customizable business processers
  2. The current .NET Remoting solution will be migrated to Windows Communication Foundation. WCF is regarded as a critical technology especially since Northwind would like to support multiple user interfaces, hosting and offline capabilities.
  3. Building out the new web based solution. After extensive research, Northwind have decided to use ASP.NET MVC. For additional capabilities in on premise solutions, like document management and business intelligence, Northwind will leverage Sharepoint.
  4. Working with the HR, they will look to increase the size of the development team from the current size of 14 to 20 in the next 2 years
  5. A training plan has been setup to ensure that all developers are adequately trained not just on the latest technologies, but also patterns, best practices, secure coding and agile processes.
  6. Working with the technology vendor to join the relevant early adopter programs.

Product Management

Northwind have decided to follow an agile strategy with respect to both development and release. They are looking to release an updated version every 4 months.

Sales and Marketing

Northwind will focus on the following areas

  1. Online Advertising. Northwind will identify the top websites related to property and advertise on those websites
  2. Events – In person events that will be held every six months. Northwind will do call downs to property management agents to drive attendance.
  3. Trial options. Northwind will make a trial software available via the hosted offering and also provide a Virtual PC for customers wanting to try the software in a hosted fashion.
  4. Webcasts and whitepapers. Northwind will plan to have a series of whitepapers and webcasts available. These will be done via a contractor.

Example 2 : Pubs

Pubs is an ISV that operates in the education industry. They provide software for managing various kinds of institutions. In the last few years, they have experienced rapid growth and expanded quickly from a team of 10 to over 70 today. With this a number of challenges have arisen.

Pubs have decided on a short term strategy and will reevaluate in a year.

The focus for the next year will be largely internal and operational. Pubs have decided on a motto of “Quality First!”

Key Focus Areas.

  1. World Class Selling: Pubs will look to implement tools and processes to ensure that sales opportunities are properly managed and tracked.
  2. Service : With the rapid growth, there has been an increased volume of calls and issues. This had led to several complaints on poor service.  A new director will be hired to focus on customer service. An investment will be made in hiring additional people and obtaining better tools to manage service requests.
  3. Technical: The developer team has grown from a team of 4 to 25 in the last 3 years. Unfortunately, no ALM methodologies have been in place. Pubs will train developers on software methodologies as well as practices like unit testing. ALM tools will be evaluated and implemented within the next 3 months.
  4. Product Quality. There have been a number of complaints around product quality. The team will focus on testing and a third party vendor will be hired to assist with defining quality procedures. The vendor will also undertake a code review to evaluate security and best practice coding. The team also look to provide support in the product to assist with troubleshooting – example writing log files, working with performance counters etc.
  5. Product Management. The releases in the next year will largely focus on quality issues. A number of quick fixes will be made available and 2 major service packs are expected to be released.
  6. Across the entire org, training will provided to ensure that individuals and teams operate effectively.
Posted: Jan 20 2009, 09:21 AM by ahmeds | with no comments
Filed under:
Catching the TFS checkout event

I recently got asked as to whether you can handle a checkout event in TFS.

TFS itself does not have a checkout event. That is, nothing happens on the server which you can trap. It does have a checkin event though.

There is a client side API, however, that you can use to get the checkout event. In this case you can use the NewPendingChange Event to trap. There are also others for checkin etc.

You can use the API in a separate program or as part of an add-in. For example, if users are working with Team Explorer and you want to capture the checkout, you will need an add-in. Here is a guide to get you started (It might be based on TFS05).

Finally, a tip.

The resolution came from the developer who first asked the question (Thanks Kevin!). If you are developing an addin and catching the NewPendingChange event - but you find that the events are not being fired, the chances are it has do with the way you got a reference to the TFS Server.

If you had the line below it will not work

tfsServer = new TeamFoundationServer(ServerName);

Modify it to below and it should do the trick. See this post for more information.

tfsServer = TeamFoundationServerFactory.GetServer(ServerName);

Posted: Jan 19 2009, 10:14 AM by ahmeds | with no comments
Filed under:
TOP 25 Most Dangerous Programming Errors

I think this should be compulsory for all developers and any programming course. Check out http://www.sans.org/top25errors/. The list has been reviewed by most vendor experts.

A few more Azure whitepapers

I mentioned some resources in the A bit on Azure post. A few more whitepapers got released. All of these are focused on the .NET Services bit. You can get it from here

More Posts Next page »