Adding the GPMC Assembly to a Visual Studio Project

This topic lists the steps required to use the Group Policy Management Console (GPMC) functionality from a Visual C# application in Visual Studio.

After you’ve ensured that the GPMC Class Library is properly installed and enabled, you can access the GPMC Class Library types from Visual Studio by adding a reference to the Microsoft.GroupPolicy.Management assembly in your Visual Studio project.

  1. Follow the steps outlined in the document, Installing the GPMC Class Library.

  2. The installation process for the GPMC Class Library adds the Microsoft.GroupPolicy.Management assembly to the Global Assembly Cache (GAC). While Visual Studio allows you to browse folders, Windows will not, by default, allow you to browse the GAC. To verify whether you can browse the GAC folder layout, open Windows Explorer to %windir%\assembly. If you see a listing of folders, including GAC, GAC_32, and GAC_MSIL, you can skip to the next step. Otherwise, if you see a listing of assemblies, you'll need to edit the registry to enable GAC folder browsing. To do that, simply use your registry editor of choice (such as RegEdt32.exe) to browse to the [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion key and then set the DisabledCacheViewer value to 0x02. (Setting this value to 0x0 will revert back to the original view.)

  3. From a Visual Studio project menu, click Project and then select the Add Reference submenu.

  4. When the Add Reference dialog box appears, click the Browse tab.

  5. In the File name text field, type %windir%\assembly\gac_msil and click Enter.

  6. Browse to the Microsoft.GroupPolicyManagement folder and double-click it.

  7. Double-click the folder whose name contains the assembly version and public key token.

  8. Select the Microsoft.GroupPolicyManagement.dll file and click OK.