title: AD RMS Managed Code Error The system cannot find the file specified. HRESULT: 0x80070002
body: <p>I'm new to Active Directory Rights Management Services (AD RMS) and I'm developing an application to use AD RMS to encrypt some documents. I'm using the interop example and I get the error - The system cannot find the file specified. HRESULT: 0x80070002 - when I try to run the code below: </p>
  
  <p>I get the error when I try to run this statement:</p>
  
  <p>Collection ipcTemplates = IPC.GetTemplates();</p>
  
  <pre><code>internal static class IPC
  {
       static IPC()
       {
            SafeNativeMethods.IpcInitialize();
       }
  
       public static Collection&lt;TemplateInfo&gt; GetTemplates()
       {
            Collection&lt;TemplateInfo&gt; templates = null;
  
            try
            {
                 templates = SafeNativeMethods.IpcGetTemplateList(null, true, true,
                                  false, false, null, null);
            }
            catch (Exception /*ex*/)
            {
                /* TODO: Add logging */
                throw; 
            }
  
            return templates;
       }
  }
  </code></pre>
  
  <p>Stack Trace:</p>
  
  <p>The system cannot find the file specified. HRESULT: 0x80070002
     at Microsoft.InformationProtectionAndControl.SafeNativeMethods.ThrowOnErrorCode(Int32 hrError) in c:\Microsoft.InformationProtectionAndControl\SafeNativeMethods.cs:line 1678
     at Microsoft.InformationProtectionAndControl.SafeNativeMethods.IpcGetTemplateList(ConnectionInfo connectionInfo, Boolean forceDownload, Boolean suppressUI, Boolean offline, Boolean hasUserConsent, Form parentForm, CultureInfo cultureInfo) in c:\Microsoft.InformationProtectionAndControl\SafeNativeMethods.cs:line 137
     at IPC.GetTemplates() in c:\IPC.cs</p>
  
  <p>Also, I have set up a post build event to make sure the manifest file gets created every time the code is compiled. The application is a WCF service hosted in a windows service. I have a very simple console app that works. </p>
  
  <p>Any help in resolving this error and any AD RMS examples using managed code would be appreciated :)</p>