使用“Microsoft.Office.Interop.Word._Document.Close”当编译时警告 [英] Compile time warning when using 'Microsoft.Office.Interop.Word._Document.Close'

查看:1126
本文介绍了使用“Microsoft.Office.Interop.Word._Document.Close”当编译时警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何解决这个警告信息?


  

办法Microsoft.Office.Interop.Word._Document.Close(Ref对象,引用对象,参考对象)和非方法之间的模糊'Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close。使用方法组。



解决方案

我已经设法解决该警告的唯一方法是使用显式转换:

VAR doc_close =(Microsoft.Office.Interop.Word._Document)_doc;
doc_close.Close();

如果您已经有一个使用的Microsoft.Office.Interop.Word 可以简化投地:

VAR doc_close =(_document)_doc;
doc_close.Close();

甚至只是

((_文档)_doc).Close();

Anyone know how to solve this warning message?

Ambiguity between method 'Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close'. Using method group.

解决方案

The only way I've managed to resolve the warning is to use an explicit cast:

var doc_close = (Microsoft.Office.Interop.Word._Document) _doc;
doc_close.Close();    

If you already have a using for Microsoft.Office.Interop.Word you can simplify the cast to:

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

or even just

((_Document)_doc).Close();

这篇关于使用“Microsoft.Office.Interop.Word._Document.Close”当编译时警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆