c# - 方法之间的歧义

标签 c# .net methods ms-office

<分区>

Possible Duplicate:
How to eliminate warning about ambiguity?

我在我的应用程序中使用 MS Office Word,使用以下代码:

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

//do it.. 

电话:

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

给出一个:

Ambiguity between method 'Microsoft.Office.Interop.Word._Application.Quit( ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit'. Using method group.

我尝试设置请求参数:

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

但它给出了同样的错误。如何解决这个问题?提前致谢!

最佳答案

你试过吗?

((_Application)wordApplication).Quit(ref nullObject,
                                     ref nullObject,
                                     ref nullObject);

关于c# - 方法之间的歧义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8758961/

相关文章:

c# - 我可以拆箱一个字符串吗?

c++ - 在 C++ 中使用嵌套开关是一种好习惯吗?有没有其他方法可以避免这种情况?

java - Java中如何返回void方法?

c# - 将 C/C++ #if 和 #elif 指令转换为 C#

c# - Automapper 5.0全局配置

c# - 如何在WPF中绑定(bind)UpdateSourceTrigger?

c# - 统计数组中字符和单词的个数

c# - jQuery 没有找到 Asp.net 转发器交替项

c# - 调整 Web 浏览器大小时调试 session 在 visual studio 中意外结束

Ruby 动态创建方法和变量