Powershell + InstallUtil: Unable to get installer types Error

While building a basic Powershell cmdlet using this tutorial, I ran into an error when trying to install the cmdlet with InstallUtil:

An exception occurred during the Install phase.
System.InvalidOperationException: Unable to get installer types in the D:\SamplePowerShellProject\bin\Debug\MyCmdlets.dll assembly.
The inner exception System.Reflection.ReflectionTypeLoadException was thrown with the following error message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..

Why did I run into this error? When building my solution in Visual Studio, I noticed that Add References didn’t have any references to the System.Management.Automation namespace. The usual solution, c/o Stack Overflow, is to find the right DLL in C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell.

In my case, I saw two subdirectories: v1.0 and 3.0. And to make it more confusing, my $PSVersionTable showed a version of 2.0!

The reason I saw this error is because I included the 3.0 version of the DLL instead of the 1.0 version. Once I switched the reference to the 1.0 version of the DLL, it installed without any issue.

About Ashiq Alibhai, PMP

Ashiq has been coding C# since 2005. A desktop, web, and RIA application developer, he's touched ASP.NET MVC, ActiveRecord, Silverlight, NUnit, and all kinds of exciting .NET technologies. He started C# City in order to accelerate his .NET learning.
This entry was posted in Core .NET, Tools and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *