solidau
solidau

Reputation: 4081

Namespace/Reference errors

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?

Upvotes: 1

Views: 395

Answers (1)

Ken
Ken

Reputation: 1985

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.

Upvotes: 1

Related Questions