0

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?

jrummell
  • 42,637
  • 17
  • 112
  • 171
MikeTWebb
  • 9,149
  • 25
  • 93
  • 132

2 Answers2

2

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.

MikeTWebb
  • 9,149
  • 25
  • 93
  • 132
0

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.

David Hirst
  • 1,890
  • 2
  • 22
  • 31
  • That's the problem, I don't have any references to Models in my solution...curious – MikeTWebb Aug 28 '12 at 15:29
  • I see that you mention that but you also mentioned that you reference a domain project, have you tried making this Copy Local? – David Hirst Aug 28 '12 at 15:45
  • AH...I see what you mean. But, yes, it is Copy Local. – MikeTWebb Aug 28 '12 at 16:26
  • What appears on line 29 of the files reported in the error? Is this the reference to your other project? – David Hirst Aug 29 '12 at 08:27
  • ....good call! I hadn't looked there and low and behold it showed code being compiled that referenced Models in a .cshtml file. I'm going to post an answer. Basically, files tht were not included in the VS solution BUT were still in the file structure on my machine were referencing Models. Therefore when I did a search for Models, I didn't get any results...but the compiler sweeps the entire directory structure – MikeTWebb Aug 30 '12 at 14:34