Macros don't run in Visual Studio 2010

2019-01-12 00:21发布

问题:

Macros in Visual Studio 2010 cannot be started any more. They don't hit a breakpoint in their first line in the macro IDE. There is no error message. Macros can still be recorded, the code is shown in the macro IDE, but newly recorded macros cannot be started either. There is no error in the macro files, at least there is no error displayed in the error list. If I add an error intentionally, the error is getting displayed in the error list.

There is a short cursor change when I start the macro, but nothing else happens, and there is no output in the output view. It looks like there is a setting or option which prevents macros from running, but I cannot find any such setting. I experience the same problem on a second computer (on the same network), so maybe some Windows (7) update caused the problem. I did use macros frequently in the past without any problems and did not change the macros code recently.

Is anyone experiencing the same problem?

回答1:

On 2014-02-11, Microsoft released bulletin MS14-009 - Important. Vulnerability CVE2014-0257 is among the list of fixes. This relates to an elevation of privileges through use of reflection to execute code normally inaccessible to the caller. Part of the solution involves disabling reflection over COM interfaces. This resulted in a family of patches for all .NET Framework and Windows combinations. You can view the list through the link above.

Microsoft released a follow-up KB2934830 to address problems with running macros through Visual Studio. You will need to edit one or more of the following files as an administrator:

VS2005:

C:\Program Files (x86)\Common Files\Microsoft Shared\VSA\8.0\VsaEnv\Vsmsvr.exe.config

VS2008:

C:\Program Files (x86)\Common Files\Microsoft Shared\VSA\9.0\VsaEnv\Vsmsvr.exe.config

VS2010:

C:\Program Files (x86)\Common Files\Microsoft Shared\VSA\9.0\VsaEnv\Vsmsvr10.exe.config

Add this under the runtime section. runtime should already exist:

<AllowDComReflection enabled="true"/> 

This should make macros execute as expected.