0

我有一个 MVC3 C# .Net Web 应用程序,我在我的应用程序上运行 aspnet_compiler 以进行预编译。我正在运行这个命令:

aspnet_compiler -v /dev/boe

Boe 是“默认网站”下开发结构中的应用程序。上面的命令产生了这个错误。

c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\dev_boe\25d5f53a\2ad742fc\App_Web_vujir5mm.0.cs(29): error CS0234: The type or namespace name 'Models' does not exist in the namespace 'BOE' (are you missing an assembly reference?)
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\dev_boe\25d5f53a\2ad742fc\App_Web_vujir5mm.2.cs(29): error CS0234: The type or namespace name 'Models' does not exist in the namespace 'BOE' (are you missing an assembly reference?)
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\dev_boe\25d5f53a\2ad742fc\App_Web_vujir5mm.3.cs(29): error CS0234: The type or namespace name 'Models' does not exist in the namespace 'BOE' (are you missing an assembly reference?)

但是,模型不在我们的解决方案中。我们的模型对象位于我们的 Web 应用程序引用的域项目中。看来编译器期望在我们的 MVC 应用程序中有一个模型引用。这是真的?还是有其他原因导致此错误?

4

2 回答 2

2

感谢 David Hirst 建议查看临时文件中的代码行,我发现了问题:

基本上,有些文件未包含在 Visual Studio 解决方案中,但仍在我机器上的文件结构中。有 3 个引用模型的 .cshtml 文件。由于这些文件未包含在解决方案中,因此它们未包含在使用 VS 的构建中。而且,由于它们不在解决方案中,所以当我搜索模型时,我没有得到任何结果......但是编译器扫描了整个目录结构,因此试图编译带有错误引用的文件。

Outstanding lesson in being sure to remove legacy code, and make sure the code base and file structures are in snyc.

于 2012-08-30T14:39:01.260 回答
0

尝试在 IIS 7.5 上使用 Razor 引擎时遇到类似错误(即使安装了 .NET 4!)

如果您的项目中有您建议的参考,您可能需要进入参考,突出显示它,转到属性并在 Copy Local 下,将其设置为 true。重新发布,希望这能像我一样解决您的问题。

于 2012-08-28T15:17:29.200 回答