使用'Microsoft.Office.Interop.Word._Document.Close'时的编译时警告

问题描述 投票:19回答:2

任何人都知道如何解决此警告消息吗?

方法'Microsoft.Office.Interop.Word._Document.Close(ref对象,ref对象,ref对象)'和非方法'Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close'之间的歧义。使用方法组。

c# compiler-warnings ambiguity
2个回答
30
投票
如果您已经有usingMicrosoft.Office.Interop.Word,则可以将转换简化为:

var doc_close = (_Document) _doc; doc_close.Close();

甚至只是

((_Document)_doc).Close();


0
投票
© www.soinside.com 2019 - 2024. All rights reserved.