0

Apparently I have 3 dlls with the same namespace (however the object browser says it only exists in one).

Usually in Resharper I can automatically resolve a reference, but in this case it won't do it. The type in question is ItemEvents_10_Event and when I search for that type here's what comes up:

enter image description here

I've tried prefixing the interface with Microsoft.Interop.Outlook, but it still complains with the same message.

Here's the usage in case that helps:

((ItemEvents_10_Event)MailItem).Send += OnSend;
((ItemEvents_10_Event)MailItem).BeforeAttachmentAdd += BeforeAttachmentAdd;
((ItemEvents_10_Event)MailItem).Write += OnInspectorSaved;

Note that I do not get any compile or runtime errors (at runtime my method never gets invoked), however the class has squiggly red lines under them which alerts me there is an issue.

The Muffin Man
  • 19,585
  • 30
  • 119
  • 191

1 Answers1

2

This may be a case of needing extern alias. The error is occuring because you have 3 assemblies (.dlls), that all contain the same class in the same namespace.

In VS, select your reference that you want to use (Can be any of the 3), and give it an alias: https://i.stack.imgur.com/uTM8G.png

You can then use this in your file as:

extern alias MyAlias;
using ItemEvents_10_Event = MyAlias::Microsoft.Office.Interop.Outlook.ItemEvents_10_Event;

This will use the ItemEvents_10_Event from the .dll with the alias.

Cyral
  • 13,999
  • 6
  • 50
  • 90