Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 Macro problem - Quit Working all together

I built a macro today in VS.. testing as I went, and it worked great. I proceeded to build another, but accidentally pasted it into EnvironmentVariables Module... I removed it, and saved, but now no Macros that I create work. I tried the built-in samples, such as insert date, and it worked, but nothing custom works.

Thanks, Ben

like image 329
Benjamin S. Avatar asked Sep 15 '10 02:09

Benjamin S.


People also ask

What is $( TargetPath?

$(TargetPath)The absolute path name of the primary output file for the build (defined as drive + path + base name + file extension).

Where are Visual Studio macros stored?

A user-defined macro is stored in a property sheet. If your project doesn't already contain a property sheet, you can create one by following the steps under Share or reuse Visual Studio project settings.

What is $( OutDir?

$(OutDir) is a Visual Studio Build Property Macro. You can see the values of macros using the Macros >> button in many Properties dialogs. For instance, in Properties->General->Output Directory, click the dropdown in the value text box, choose Edit..., and in the resulting dialog, click the Macros >> button.

How do I edit macros in Visual Studio?

Edit the macroOn the DEVELOPER tab, in the Code group, click Macros. In the Macro name box, click the macro that you want to edit. Click Edit. The Visual Basic Editor appears.


2 Answers

Not to steal anybody's thunder, but I was unable to add comments as I'm apparently considered a person of ill repute, so I'll just add this information as a separate answer.

The page cited in a previous (correct and very helpful) answer by David Coster has since been updated to reflect the fact that it is no longer necessary to uninstall the offending update. Macros can be re-enabled by changing some config files, as described below:

Update (February 18): To restore Visual Studio 2010 macros functionality without removing Windows updates, you can add the AllowDComReflection configuration setting to vsmsvr10.exe.config, vsaenv10.exe.config and devenv.exe.config files (note, you need to run your editor with admin rights for correct modification of these files):

<configuration>
    <runtime>
        <AllowDComReflection enabled="true"/>

On a 64-bit Windows machine default paths to these files are:

"C:\Program Files (x86)\Common Files\Microsoft Shared\VSA\9.0\VsaEnv\vsmsvr10.exe.config"
"C:\Program Files (x86)\Common Files\Microsoft Shared\VSA\9.0\VsaEnv\vsaenv10.exe.config"
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config"

Each of these files already has the runtime section, you just need to add the line.

Visit the page cited for full details.

like image 107
user3324937 Avatar answered Oct 18 '22 13:10

user3324937


An update on this: in Feb 2014 Microsoft released an update that broke macros in Visual Studio products. After reading the following link I uninstalled KB2898869 on my Win 7 x64 machine and they are working again.

See this link for the full story.

Here is a bit from that link:

Installing recent February 11, 2014 Windows updates breaks Visual Studio 2010 macros functionality. Macros just don’t run any more without an error message. More specifically, it is MS14-009 update “Vulnerabilities in .NET Framework Could Allow Elevation of Privilege (2916607)” (rated as Important) breaks macros. And more specifically it is the Elevation of Privilege part of this update.

            .NET 4.5.1  .NET 4.5    .NET 4
Windows 8.1 KB2898871       
Windows 8   KB2898870   KB2898865   
Windows 7   KB2898869   KB2898864   KB2898855
Windows XP              KB2898855
like image 21
David Coster Avatar answered Oct 18 '22 13:10

David Coster