Friday, June 6, 2008

PowerShell v2 CTP/CTP2 error: "Error loading the extended type data file"

Over the last few months since the v2 CTP was released last November, from time to time, I've come across users getting this error when starting the v2 CTP/CTP2:

------------------------------------------------------------------------
Error loading the extended type data file:
Microsoft.PowerShell.Core,
C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(257) :
Error in type "System.DirectoyServices.DirectoryEntry":
Exception: Cannot convert "Microsoft.PowerShell.AdapterCodeMethods" to "System.Type".
Microsoft.PowerShell.Core,
C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(264) :
Error in type "System.DirectoyServices.DirectoryEntry":
Exception: Cannot convert "Microsoft.PowerShell.AdapterCodeMethods" to "System.Type".
Microsoft.PowerShell.Core,
C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(275) :
Error in type "System.IO.DirectoryInfo":
Exception: Getter method should be public, non void, static, and have one parameter of type
PSObject.
Microsoft.PowerShell.Core,
C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(306) :
Error in type "System.IO.FileInfo":
Exception: Getter method should be public, non void, static, and have one parameter of type
PSObject.
------------------------------------------------------------------------

What seems to have happened in most cases is that an attempt was made to uninstall PowerShell v1 manually.

I'm going to find some time hopefully before the end of the month to test this, but I believe the root cause is that when v1 is removed manually, DLLs in the .NET GAC (C:\Windows\Assembly) are left there.

It appears that the v2 CTP installer isn't set to overwrite these DLLs, so they remain as the older counterpart, and cause issues with v2 being able to load properly without any errors.