[英]Can't Add Strongly-Typed View With Model From Referenced Assembly in ASP.NET MVC 3
I have a solution with an ASP.NET MVC 3 project, and a class library project. 我有一个ASP.NET MVC 3项目和一个类库项目的解决方案。 I created a reference to the class library, "Commands", in the web project, which is resolving; 我在要解决的Web项目中创建了对类库“ Commands”的引用。 copy-local is also set to true and Commands.dll is being copied into the web project's bin directory. copy-local也设置为true,并将Commands.dll复制到Web项目的bin目录中。
When I try to add a strongly-typed view, selecting a class from Commands as the model, I receive a "Could not load file or assembly" error for the Commands assembly. 当我尝试添加强类型视图时,从Commands中选择一个类作为模型,我收到Commands程序集的“无法加载文件或程序集”错误。
I've tried removing and re-adding the reference, cleaning and rebuilding the solution, etc. but still have the problem. 我试过删除并重新添加参考,清理和重建解决方案等,但是仍然有问题。
Something else odd about this is that when I click "Add view" in the controller to get to the add view dialog, the model in the referenced assembly is available in the "Model class:" drop-down. 对此还有些奇怪的是,当我在控制器中单击“添加视图”以进入“添加视图”对话框时,在“模型类:”下拉列表中可以找到被引用程序集中的模型。
Try using the Fully qualified name for the model class in your view. 尝试在视图中使用模型类的完全限定名称。
Ex : @model YourClassLibraryNameSpace.YourClassname
例如: @model YourClassLibraryNameSpace.YourClassname
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.