title: Cannot add reference to Outlook 2016 (Office 365) Interop (16.0.0.0)
body: <p>I'm trying to add a reference to 'Microsoft Outlook 16.0 Object Library' in a C# .NET 4.6.1 WPF project, because I have office 2016 installed. Previous versions of the Object Library are incompatible with the 2016 version of office.</p>
  
  <p>If I use Excel's VBA editor, 'Microsoft Outlook 16.0 Object Library' is listed, and exists in <code>C:\Program Files\WindowsApps\Microsoft.Office.Desktop_16010.9126.2116.0_x86_8wekyb3d8bbwe\VFS\ProgramFilesCommonX86\Microsoft Shared\OFFICE16\MSOUTL.OLB</code>, as you can see below:</p>
  
  <p><a href="https://i.stack.imgur.com/vlxaG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vlxaG.png" alt="enter image description here"></a></p>
  
  <p>However, when I use Visual Studio, the COM tab does not list 'Microsoft Office 16.0 Object Library', and when I try to browse to <code>C:\Program Files\WindowsApps</code>, i get 'You dont currently have permission to access this folder', and clicking 'Continue' (to get access) results in 'You have been denied permission to access this folder'.</p>
  
  <p>So basically, the Office 2016 dlls seem to have been tucked away in a folder that is inaccessible to man, dog, and local administrator.</p>
  
  <hr>
  
  <p>All I'm trying to do is connect to the open Outlook application, and then send an email with an attachment, so perhaps another question to ask is, is there some new fangled way to communicate with Outlook 2016 that hasn't cropped up in my Googleathon?</p>
  
  <hr>
  
  <p>Also worth noting is that my version of office is installed as a 'Windows Store Application' and therefore does not appear on the usual Add/Remove programs list, so I can't find any 'repair' options for the installation.</p>
  
  <p>Thanks.</p>
  
  <hr>
  
  <p>Further investigation reveals that I am doing the right thing - trying to add a COM reference to 'Microsoft Outlook 16.0 Object Library' is now the correct way to target Outlook ... <a href="https://stackoverflow.com/a/21018418/5040941">https://stackoverflow.com/a/21018418/5040941</a>.</p>
  
  <p>I've checked the GAC, and the assemblies aren't registered. I've done a repair via the 'Apps and Features' right-click start menu option, and they still aren't appearing - it's as if the Windows Store apps just shove their dlls into the <code>Program Files\WindowsApps\*</code> folder, and don't bother to register them in the GAC.</p>
  
  <hr>
  
  <p>In answer to the much appreciated comments!</p>
  
  <p>Using the following code</p>
  
  <pre><code>Outlook.Application application = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
  </code></pre>
  
  <p>If I use the nuget <code>Microsoft.Office.Interop.Outlook</code> package, i get a <code>System.Runtime.InteropServices.COMException: 'Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))'</code> exception.</p>
  
  <p>If I try using <code>Microsoft Outlook 15.0 Object Library</code> or <code>Microsoft Outlook 14.0 Object Library</code> references via the Assemblies/Extensions tab of Add Reference, I get a <code>System.Runtime.InteropServices.COMException: 'Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))'</code> exception.</p>
  
  <p>I don't think accessing the WindowsApps folder is the way to go.
  Firstly, it's locked down for some reason which typically indicates the potential for trouble if i start digging around and changing security permissions, not to mention the fact that maintaining a copy of the latest dll in my solution will undoubtedly add unnecessary complexity to my project.</p>
  
  <p>Secondly, but more importantly, if I have office installed, and I can access 'Microsoft Outlook 16.0 Object Library' from Excel Vba, then why can't I access it from Visual Studio?</p>
  
  <p>There is obviously some issue with the installation not registering the dlls properly, only Excel has some trick it uses to make the reference available anyway.</p>
  
  <hr>
  
  <p>Has anyone reading this managed to install Office 365/2016 Windows Store and found a reference to 'Microsoft Outlook 16.0 Object Library' in Visual Studio?</p>
  
  <p>Am I the only with this problem?! Because it affects multiple computers in my office running Windows 10 and Office 365 ...</p>
  
  <hr>
  
  <p>In answer to RogerN (thanks), please see the image below - I don't have Microsoft.Office.Interop.Outlook version 16 listed, and Microsoft.Office.Core isn't listed either.</p>
  
  <p><a href="https://i.stack.imgur.com/9GGTJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9GGTJ.png" alt="enter image description here"></a></p>
  
  <p>If I try to use the v15 library, I get the following error:</p>
  
  <p><code>System.Runtime.InteropServices.COMException
    HResult=0x80040154
    Message=Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
    Source=mscorlib</code></p>
  
  <hr>
  
  <p><strong>*AND THE ANSWER IS *</strong></p>
  
  <p>The two computers I bought from Dell are 64 bit, but they come preinstalled with 32 bit, windows store versions of MS Office 2016/365.</p>
  
  <p>In order to fix the problem, I had to:</p>
  
  <ul>
  <li>uninstall the store app from <code>Settings &gt; Apps &gt; Apps&amp;Features &gt; Microsoft Office Desktop Apps &gt; Uninstall</code></li>
  <li>log into portal.office.com</li>
  <li>select install office apps, advanced, choosing the 64-bit version</li>
  </ul>
  
  <p>Quite why Dell think we want 32 bit versions installed on 64 bit machines, or why someone from Microsoft hasn't posted a solution to this problem, is beyond my understanding, but nevertheless, RogerN was correct. Thanks to everyone for taking time out their days to help me out.</p>