Method ambiguity

Possible duplicate:
How to eliminate the ambiguity warning?

I work with MS Office Word in my application using the following code:

var wordApplication = new Microsoft.Office.Interop.Word.Application(); var wordDoc = wordApplication.Documents.Open(ref fileName); //do it.. 

call:

 wordDoc.Close(); wordApplication.Quit(); 

to give:

The ambiguity between the Microsoft.Office.Interop.Word._Application.Quit (ref object, ref object, ref object) 'method and the non-method' Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit. Using the group of methods.

I tried to set the query arguments:

 object nullObject = Type.Missing; wordDoc.Close(ref nullObject, ref nullObject, ref nullObject); wordApplication.Quit(ref nullObject, ref nullObject, ref nullObject); 

but he gives the same error. How to fix it? Thanks in advance!

+6
source share
1 answer

Have you tried this?

 ((_Application)wordApplication).Quit(ref nullObject, ref nullObject, ref nullObject); 
+11
source

Source: https://habr.com/ru/post/905317/


All Articles