Reference MVC project from Windows Application project
I want to use reflection to get all controller/actions names. To do so, i need to reference the MVC project from the WinApp project. The thing is that when I reference it (Add Reference > Projects > MyMVC) , include the namespace (using MyMVC.Controllers;) and build the project, I get the following error:
The type or namespace name 'MyMVC' could not be found (are you missing a using directive or an assembly 开发者_StackOverflow中文版reference?)
At first, after including the namespace, the Intellisense works alright, but while building the project a warning shield appars above the reference and then it dissapears. After that, the Intellisense stop working.
Any ideas?
I had to change the target framework from .NET Framework 4 Client Profile to .NET Framework 4, now it works :)
Have a look at the references folder in your project. Is there an exclamation mark at the reference of your MVC Project? If so, you can hover it to get more information about the compilation problem that occurred.
Edit: Have you perhaps referenced the dll from within the bin\Debug folder of your MVC project? If you are trying to build a Release version that would probably not work.
If this is not the case, click on the reference, open the properties window and look at the path to the assembly. Make sure that the assembly is actually still residing in the path shown and there are no file / user permission problems.
The .NET framework must to be the same. For changing the framework, select the project, press ALT+Enter, go to the Application tab and change the Target framework for the same as the MVC project.
精彩评论