Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# ASP.NET MVC Forms Finishing Our CRUD Web App Updating Our Controller to Handle Updates

Dmitri Mikhalev
Dmitri Mikhalev
4,462 Points

The type or namespace name 'Treehouse' could not be found

So after this last step when I extracted the ValidateEntry method, a bunch of errors popped up all over the place. One of the most common ones is "CS0246 The type or namespace name 'Treehouse' could not be found (are you missing a using directive or an assembly reference?)" .

it shows up in _Layout, Index and add.

In Add.chtml, I am actually @using Treehouse.FitnessFrog.Models. but for some reason it doesn't work? also the Add.cshtml, "Treehouse" in "@using Treehouse.FitnessFrog.Models" is underlined in red, telling me that "Using directive is unnecessary, followed by the error above.

As I said, there is a bunch of other errors as well, but lets start with these maybe?

what am I doing wrong?

Steven Parker
Steven Parker
231,269 Points

You'll need to share your code to make it possible for folks to replicate the issue. Perhaps create a public repo?

3 Answers

Dmitri Mikhalev
Dmitri Mikhalev
4,462 Points

Okay, sorry. There is just so much.

I'll try to simplify.

How about this?

@model Treehouse.FitnessFrog.Models.Entry
@using Treehouse.FitnessFrog.Models

The "Treehouse" is underlined with red in like every document, with a statement that says "CS0246 The type or namespace name 'Treehouse' could not be found"...

I'm also having a bit of a hard time to remember... where it was supposed to be found...

Also this: (this is in the partial view _EntryForm.cshtml

                    <label class="radio-inline">
                        @Html.RadioButtonFor(m => m.Intensity,
                            Entry.IntensityLevel.Low) @Entry.IntensityLevel.Low

                        </label>
                        <label class="radio-inline">
                            @Html.RadioButtonFor(m => m.Intensity,
                                Entry.IntensityLevel.Medium) @Entry.IntensityLevel.Medium
                            </label>
                            <label class="radio-inline">
                                @Html.RadioButtonFor(m => m.Intensity,
                                    Entry.IntensityLevel.High) @Entry.IntensityLevel.High
                                </label>
                            </div>
                        </div>

So basically, there is nothing wring with the code above but the "Entry" keeps being underlined with red even though I've added the using directive... I guess this will go away when the Treehouse namespace is found...

Interesting fact is that when I build the page, it builds successfully and I can run it in all its glory... but the errors are still there

Steven Parker
Steven Parker
231,269 Points

Unfortunately, there's no easy way to "snapshot" an entire VS project (like you can with workspace projects) to make it easy for someone to analyze your code. That's why I suggested something like a github repository.

Unlike cs, the cshtml code is dynamically interpreted so there's not much that can be detected by the build process other than syntax errors. But it sounds like you may have accidentally excluded the cs module where the namespace and/or model is defined from the project.

Dmitri Mikhalev
Dmitri Mikhalev
4,462 Points

Alright, thanks anyway, I'll take my time to create a github-thing next time :)

I just copied and pasted the methods like were not supposed to do and then it worked just fine for some reason :)

Steven Parker
Steven Parker
231,269 Points

Even one little typo can sometimes be big trouble.   :see_no_evil: