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.
I know it is not the answer you are looking for, but just in case somebody needs to get the workaround working:
DTE.ActiveDocument.Selection().TopPoint.CreateEditPoint().Insert("//123")
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.
User contributions licensed under CC BY-SA 3.0