I have installed Visual Studio Tools for Office (VSTO) so can use Microsoft.Office.Interop.Outlook.dll for my .Net applications. However, I get the error below. I think it is related to registry keys but I am not sure. Microsoft.Office.Interop.Outlook.dll exists but the registry is looking for it somewhere else maybe? I used to use this .dll library on my previous computer w/o problem. By then, I did not install VSTO but it was something similar. Do you have any idea how can I fix the issue?
3rd line raises the exception below on the screenshot
using Microsoft.Office.Interop.Outlook;
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
but they didn't help
I backed up and deleted both Win64 Keys under
00062FFF-… 2DF8D04C…
Then it worked.
Here is my guess:
We upgraded the latest 2021 Office (64 bit) and downgraded back to 2016 Office (32 bit) and I believe this was the root of the problem.
I think VS was trying to use 64-bit Outlook but of course it was not there. So, it was showing broken references (yellow triangle sign) on references of
Microsoft.Office.Core Microsoft.Office.Interop.Outlook
I tried to browse and connect the library (i.e., right-click References > Add Reference > Browse) directly but had no luck. I think VS was still referring to 64-bit Office/Outlook
When I removed the Win64 keys VS was forced to use 32-bit Office which exists and it worked fine.
It took a while to figure this out I hope this answer helps other users. By the way, I don't know if deleting these registries will cause any problem when we upgrade later Office version again.