1

I have an MVC Controller that cannot see another namespace in the using statement.

Specifically this line of code:

using TRN.Website.Tools;

Errors with:

The type or namespace name 'Tools' does not exist in the namespace 'TRN.Website' (are you missing an assembly reference?)

Other parts of my project can see the TRN.Website.Tools namespace however.

I tried adding the namespace to web.config but this had no effect.

EDIT: Sorry all I have missed out a vital bit of information. TRN.Website.Tools is just a folder with the namespace TRN.Website.Tools in the same project. It is not a separate project or a dll.

2
  • 2
    Are you missing an assembly reference? Commented Dec 30, 2013 at 10:39
  • Have you import the dll into your project references? Commented Dec 30, 2013 at 10:41

5 Answers 5

3

My guess: You have multiple projects in you solution and you have multiple libraries (dlls) that their names starts with TRN.Website and you added reference to one of these dlls in your MVC project. you have to add reference to the other one too.

Sign up to request clarification or add additional context in comments.

Comments

3

Solved but in a really strange way.

I added another class in the Tools folder and after that the error disappeared.

Very very odd.

Comments

3

Check your Build Action of your class in properties window. It must be 'Compile'.

1 Comment

I even added the 'aspnet folder' App_Code and the class default action was set to content. Amazing that five years later (using MVC5) and stuff like this still trips us up.
2

Your ASP.NET MVC project does not contain a reference to the assembly that contains the TRN.Website.Tools namespace. You have to reference that from your ASP.NET MVC project in order to use it.

If TRN.Website.Tools is a project in your Solution, you can just add a Project reference to it.

If it isn't a project in your Solution, you'll have to add a reference to the compiled DLL to your ASP.NET MVC project.

1 Comment

Accepted as while this did not solve my problem it was a well written answer that will help others.
0

In my case, I had not checked in the "X.csproj" file to TFS, so the new controller I created was not being found in my testing environments as a valid controller.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.