“Exception has been thrown by the target of an invocation.” when building a Visual Studio 2010 VSPackage

柔情痞子 提交于 2020-01-21 07:42:46

问题


I recently create a couple of VSPackages for some Visual Studio extensions (menu bar/command). I compiled them correctly yesterday, checked into TFS (i'm the only one touching this project, FYI). I had already installed these extensions and were working fine. Today it doesn't compile! I get the following error:

Exception has been thrown by the target of an invocation.

This doesn't tell me anything, so i fired up Visual Studio with the following command:

devenv.exe /Rebuild > out.log

In my out.log, I see the following:

C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\VSSDK\Microsoft.VsSDK.targets(420,5): error : Exception has been thrown by the target of an invocation.

I have been stuck on this for hours and can no longer build these VSPackages. Anyone? This is really frustrating. I have already tried cleaning project/rebuilding/build using Visual Studio itself (not command line)


回答1:


I've experienced this issue several times in both vs2010 and vs2012, and manually deleting the "bin" and "obj" folders from the project then doing a "rebuild" normally does the trick.




回答2:


Further to the answer provided by the OP, I will provide it here for completeness instead of relying on the external link remaining live:

Quoted directly from the MSDN forum answer:

Do you happen to have these extensions installed to the AllUsers location (i.e. %VSInstallDir%\Common7\IDE\Extensions)?

You mentioned in your initial post that "I had already installed these extensions and were working fine."

The task that's failing (based on the line number in the targets file) is the UninstallExtension task. The only reason I'm thinking this task would execute and fail in your situation is if you're building an extension that's already installed to the Common7\IDE\Extensions directory.

Regards, Aaron

I find myself on this question because of exactly the same build issue of a VSIX Installer Project for our project templates. This solved my issue.

Indeed, I uninstalled the prior version of our templates and the build occurs without issue.




回答3:


Have you double checked that all of your projects are using compatible framework versions?
As in you can't use a .Net 4.0 assembly in a .Net 3.5 project.




回答4:


Is the project linked with source control like TFS? If so then take latest from TFS and try again.




回答5:


Are you running Visual Studio as Administrator?

Maybe you have insufficient rights for some file (copy/move/delete) especially in bin or obj folders.



来源:https://stackoverflow.com/questions/5823691/exception-has-been-thrown-by-the-target-of-an-invocation-when-building-a-visu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!