1

My solution wont compile. I am getting an error message when i try to compile my project:

Error 2 The type or namespace name 'Security' does not exist in the namespace 'Base' (are you missing an assembly reference?)

It is confusing, however, because i have referenced the project and that is the correct namespace! here's the solution setup

Solution Base - Base.Domain - Base.Security - Base.Tests - Base.WebUI

in Base.Security I have a custom role provider file like this:

namespace Base.Security.Providers
{
    public class EFRoleProvider : System.Web.Security.RoleProvider
    {
        //code here
    }
}

I have referenced Base.Security in Base.Tests and in Base.Tests I have the following file (that is giving me error):

using Base.Security.Providers;

namespace Base.Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = new EFRoleProvider();
            //more stuffs
        }
    }
}

I don't get it.. why can I not access Base.Security types from Base.Tests?

3
  • If you right-click on your project and click on Properties, what does your namespace and assembly name say? Also, if you remove your using directive and right click on EFRoleProvider and click Resolve, what assembly does it think its suppose to use? Commented Nov 20, 2012 at 21:13
  • Does the solution build correctly with Program removed? Sometimes an error message like this that doesn't really make sense is symptomatic of a deeper issue in a supporting reference/assembly. Commented Nov 20, 2012 at 21:13
  • Are you referencing the project or the assembly? Have you tried a full clean and rebuild? Commented Nov 20, 2012 at 21:13

1 Answer 1

1

Make sure your projects are built against the same .NET version. I've had this issue when adding a reference to a .NET 3.5 project from a .NET 4.0 project.

To check/change the .NET version right click on your project, select properties, and under the "Application" tab make sure the "Target Framework" is identical for each project.

Your code looks correct, it's an issue with the way the reference is set up.

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

3 Comments

that was it! I had the Base.Tests project using ".NET Framework 4.0 Client Profile" instead of ".NET Framework 4.0"... added a few additional references and it works now! will accept this as answer when timer is up. Any insight on the differences between regular 4.0 and 4.0 "client profile"?
Also, i'm pretty sure the others were .NET 4.0 by default - why does the console app default to the "Client profile" version?
I found this article: blogs.msdn.com/b/jgoldb/archive/2010/04/12/… that describes it pretty well. I'm not sure why the error message isn't more useful.

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.