Question

I have an MVC3 C# .Net web app and I am running aspnet_compiler on my app in order to precompile. I am running this command:

aspnet_compiler -v /dev/boe

Boe is the app in the dev structure under "Default Web Site". The above command is producing this error.

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?)

However, Models isn't in our solution. We have our Model objects in a Domain project that is referenced by our web app. It appears that the compiler is expecting a Models reference in our MVC app. Is this true? Or is something else causing this error?

Was it helpful?

Solution

I have had a similar error when trying to use the Razor engine on IIS 7.5 (even though .NET 4 was installed!)

If you have a reference in your project as you suggest you may need to go into references, highlight it, go properties and under Copy Local, set this to true. Re-Publish and hopefully this will solve your problem as it did mine.

OTHER TIPS

Thanks to David Hirst's suggestion to look at the line of code in the temp file I found the issue:

Basically, there were files that were not included in the Visual Studio solution BUT were still in the file structure on my machine. There were 3 .cshtml files referencing Models. Since the files were not included in the solution, they were not included in a Build using VS. And also, since they were not in the solution, when I did a search for Models, I didn't get any results...but the compiler sweeps the entire directory structure and therefore tried to compile the files with the bad references.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top