【发布时间】:2018-07-02 04:15:13
【问题描述】:
根据这个问题Can the DebuggerDisplay attribute be applied to types one doesn't own 提出的问题,是否可以将DebuggerDisplay 属性应用于来自外部程序集的类型?
如果是这样,有没有办法专门将其应用于Microsoft.Office.Interop.Word.Range?
我尝试了以下代码,但它不起作用:
<Assembly: DebuggerDisplay("text: {Text}", Target:=GetType(Word.Range))>
在运行时调试器显示此字符串:
{System.__ComObject}
但“System.__ComObject”不可访问,因为它是“朋友”。
【问题讨论】:
-
调试器可能无法像运行时代码那样使用用于 COM 对象的透明代理。改用
DebuggerTypeProxy(即使工作量更大) -
@JeroenMostert 你能举一个 DebuggerTypeProxy 的例子吗?
-
Sure。 (尽管有标题,但它也涵盖了
DebuggerTypeProxy。)
标签: .net debugging com vsto ms-office