Wednesday, July 15, 2009

MMC 3.0 managed snap-ins on WinXP

The problem:

I needed to do some stuff with snap-ins and I didn't want to take the hit of building a new dev box -- but on my XP box I was getting:

>InstallUtil  .\ManagedSnapIn.dll
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.3053
Copyright (c) Microsoft Corporation.  All rights reserved.


Running a transacted installation.

Beginning the Install phase of the installation.
See the contents of the log file for the C:\ManagedSnapIn\bin\Debug\ManagedSnapIn.dll assembly's progress.
The file is located at C:\ManagedSnapIn\bin\Debug\ManagedSnapIn.InstallLog.

Installing assembly 'C:\ManagedSnapIn\bin\Debug\ManagedSnapIn.dll'.
Affected parameters are:
   logtoconsole =
   assemblypath = C:\ManagedSnapIn\bin\Debug\ManagedSnapIn.dll
   logfile = C:\ManagedSnapIn\bin\Debug\ManagedSnapIn.InstallLog
An exception occurred while trying to find the installers in the C:\ManagedSnapIn\bin\Debug\ManagedSnapIn.dll assembly.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Aborting installation for C:\ManagedSnapIn\bin\Debug\ManagedSnapIn.dll.

An exception occurred during the Install phase.
System.InvalidOperationException: Unable to get installer types in the C:\ManagedSnapIn\bin\Debug\ManagedSnapIn.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..

The solution:

As noted here, the mmcperf tool registers 3 MMC assemblies to the GAC for you

>mmcperf.exe
Successfully installed assembly C:\WINDOWS\system32\MMCEx.dll to the Global Assembly Cache (GAC).
Successfully installed assembly C:\WINDOWS\system32\MMCEx.dll to the Native Images Cache.
Successfully installed assembly C:\WINDOWS\system32\MMCFxCommon.dll to the Global Assembly Cache (GAC).
Successfully installed assembly C:\WINDOWS\system32\MMCFxCommon.dll to the Native Images Cache.
Successfully installed assembly C:\WINDOWS\system32\Microsoft.ManagementConsole.dll to the Global Assembly Cache
Successfully installed assembly C:\WINDOWS\system32\Microsoft.ManagementConsole.dll to the Native Images Cache.

which let the InstallUtil run successfully -- but you could probably get away with just copying them into the folder with the snap-in (you need the last as an explicit reference anyway).

No comments :