来自 Windows 应用程序项目的参考 MVC 项目
我想使用反射来获取所有控制器/操作名称。为此,我需要从 WinApp 项目引用 MVC 项目。问题是,当我引用它(添加引用 > 项目 > MyMVC)、包含命名空间(使用 MyMVC.Controllers;)并构建项目时,我收到以下错误:
类型或命名空间名称 'MyMVC' 无法被发现(您是否缺少 using 指令或程序集引用?)
首先,在包含命名空间后,Intellisense 工作正常,但在构建项目时,引用上方会出现一个警告盾,然后它消失。之后,智能感知停止工作。
有什么想法吗?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我必须将目标框架从 .NET Framework 4 Client Profile 更改为 .NET Framework 4,现在它有效:)
I had to change the target framework from .NET Framework 4 Client Profile to .NET Framework 4, now it works :)
查看项目中的引用文件夹。您的 MVC 项目的引用处是否有感叹号?如果是这样,您可以将其悬停以获取有关发生的编译问题的更多信息。
编辑:您是否可能从 MVC 项目的 bin\Debug 文件夹中引用了 dll?如果您尝试构建可能无法工作的发布版本。
如果不是这种情况,请单击参考,打开属性窗口并查看装配体的路径。确保程序集实际上仍然驻留在显示的路径中,并且不存在文件/用户权限问题。
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.
.NET 框架必须相同。要更改框架,请选择项目,按 ALT+Enter,转到应用程序选项卡并将目标框架更改为与 MVC 项目相同的目标框架。
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.