问题
I have a Visual Studio 2010 solution that contains multiple projects. One of these projects is a library, which I have added a method to. Within visual studio I can navigate from the method call in my main project to the method in the library, but when I attempt to build/run the solution it gives me a "does not contain a definition for 'My_Method'". What am I doing wrong?
回答1:
It looks as if the library project isnt being rebuilt on each run, assuming that the project reference is correctly added (right click on references
-> add reference
-> select your library project)
You should make sure that your library is being rebuilt when you run.
To do so :
Right click on your
Solution
Click on
Configuration manager
(approximative translation)- Make sure that the
build
is checked, if not, check if for thelibrary
project
回答2:
Seems you are not rebuilding the library project and/or you are referencing the output binary (dll) directly. To solve this you can do one of the following
- Make sure you rebuild the library project, and reference the updated binary/dll
- Reference the project directly if it's part of your solution, this way, every time you rebuild the dependent project, it will rebuild the library project. The drawback to this is, if you have too many projects, it will slow you (re)builds
来源:https://stackoverflow.com/questions/9826167/rebuild-visual-studio-library-project-reference