在 VS2010 宏中设置文本时操作中止(HRESULT 异常:0x80004004 E_ABORT)
一些非常简单的宏在 VS2010 中对我不起作用。例如,如果我这样做:
DTE.ActiveDocument.Selection.Text = "123"
这会很好地工作,但如果我输入,
DTE.ActiveDocument.Selection.Text = "//123"
则会失败,并出现我在标题中包含的丑陋的中止消息。这是我在 C++ 源代码编辑器窗口中运行它时的情况。有各种各样的符号字符都会导致将文本分配给“Selection.Text”以这种方式失败。这个在VS2008中没有问题。
不过网上似乎没有这方面的信息,所以我想这一定是我的设置有问题。我知道可以通过创建编辑点然后使用“插入”方法来解决该问题,但有时令人烦恼的是,我无法在不先编辑的情况下仅记录和运行临时宏。
我想知道:
a)是否有其他人经历过这种情况?
b)是否有人知道解决方案,或者如何找到解决方案?
我的插件是: 代码合作者, 虚拟机调试器, VSBuildStatus - 尽管我很确定问题在添加这些之前就已经存在了。
我的扩展是: 安赫SVN, 指挥形象, 生产力电动工具, 视觉辅助X, Visual Studio 颜色主题编辑器 - 再次,据我所知,该问题早于大多数扩展的安装。
我在 64 位 Windows 7 上运行 VS2010。
Some very simple macros don't work for me in VS2010. For instance if I do:
DTE.ActiveDocument.Selection.Text = "123"
this will work fine, but if instead I type
DTE.ActiveDocument.Selection.Text = "//123"
then this fails with the ugly abort message that I included in the title. This is when I run it in a C++ Source Editor window. There is an assortment of symbol characters that all cause the assignment of the text to 'Selection.Text' to fail in this way. There was no problem with this in VS2008.
There appears to be nothing about this on the web though, so I'm thinking that it must be a problem with my setup. I am aware that it is possible to get around the problem by creating an edit point and then using the 'Insert' method, but it's sometimes annoying that I can't just record and run a temporary macro without editing it first.
I'm wondering:
a) Whether anyone else has experienced this?
b) Whether anyone knows of a solution to it, or how to track down a solution?
My addins are:
Code Collaborator,
VMDebugger,
VSBuildStatus -
although I'm pretty sure that the problem existed before these were added.
My extensions are:
AnkhSVN,
CommandingImage,
Productivity Power Tools,
Visual Assist X,
Visual Studio Color Theme Editor -
again, as far as I remember, the problem predates most of these extensions being installed.
I am running VS2010 on 64-bit Windows 7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这不是您正在寻找的答案,但以防万一有人需要解决方法:
I know it is not the answer you are looking for, but just in case somebody needs to get the workaround working:
我今天开始使用一直运行良好的宏(并且我广泛使用)来实现这一点。我想知道为什么会这样。也许是由于 Windows 更新所致?
[更新]
Christopher Oezbek 的修复也适用于这个问题。
I started getting this today with macros that have been working just fine (and which I use extensively). I wonder why that would be. Perhaps it is due to a Windows update?
[Update]
The fix by Christopher Oezbek does work for this problem too.