Word.ApplicationClass WordApp = new Word.ApplicationClass(); object missing = System.Reflection.Missing.Value; Word.Document aDoc = WordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing); aDoc.Close(ref missing, ref missing, ref missing); WordApp.Quit(ref missing, ref missing, ref missing); |
The warning is: Warning 1 Ambiguity between method 'Word._Document.Close(ref object, ref object, ref object)' and non-method 'Word.DocumentEvents_Event.Close'. Using method group.
The two Close candidates look pretty different to me ... what is the problem and how can I resolve this
Cheers, RL

Compiler Warning CS0467
D3lta
Robert Nguyen
> One is a method, whereas the other is an event.
Sure, but this doesn't answer the question, why are the Close() method of one interface and Close event of the other not distinguishable by their signature Is this a compiler bug: surely only the method is usable in this context
rfinlay
Now I look more carefully, I see Word.Document is an interface, and has multiple base types, namely _Document and DocumentEvents_Event interfaces. But I'm still puzzled as to why the Close() method of one and Close event of the other are (suddenly) not distinguishable by their signature. Does overloading work differently with interfaces, or this a VS2005 bug
Cheers, RL
Vhii
Word.ApplicationClass WordApp = new Word.ApplicationClass();
object missing = System.Reflection.Missing.Value;
Word.Document aDoc = WordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
((Word._Document)aDoc).Close(ref missing, ref missing, ref missing);
WordApp.Quit(ref missing, ref missing, ref missing);
or
Word.
ApplicationClass WordApp = new Word.ApplicationClass();object missing = System.Reflection.Missing.Value;
Word.Document aDoc = WordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);
#pragma warning disable 0467
aDoc.Close(ref missing, ref missing, ref missing);
#pragma warning restore 0467
WordApp.Quit(ref missing, ref missing, ref missing);
bet the 1st one is better.
nojetlag