Reputation: 4655
I'm using C#.net 4.0 with Visual Studio 2010. I am getting the error
Error 10 The type or namespace name 'IRange' could not be found (are you missing a using directive or an assembly reference?) C:\git\emtexporter\EMTExporter.IRepository\IRangeRepository.cs 11 27 EMTExporter.IRepository
IRange is an interface in the project EMTExporter.IEntities and the project IEntities builds successfully. IRange.cs has the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wiggle.EMTExporter.IEntities;
namespace Wiggle.CategoryXMLExporter.IEntities
{
interface IRange
{
long ID { get; }
Dictionary<ILanguage, string> rangeNames { get; set; }
}
}
The problem occurs in IRangeRepository.cs which has the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wiggle.EMTExporter.IEntities;
namespace CategoryXMLExporter.IRepository
{
interface IRangeRepository
{
Dictionary<string,IList<IRange>> getAllRanges();
}
}
I am referencing EMTExporter.IEntities in the IRepository project. I have no idea what could be going wrong!
edit: the issue was that the project was changed from CategoryXMLExporter to EMTExporter, but I hadn't updated the Assembly name and Default namespace of the project. Updated that, made the interface public and now it works!
Upvotes: 0
Views: 1165
Reputation: 173
In addition to what has been mentioned above, sometimes you may need to ensure the referenced library is configured as being built under the selected active configuration and platform.
In Visual Studio 2012 or 2013, right-click on the Solution and chose "Configuration Manager".
For the selected "Active Solution Configuration" (e.g. "Debug" or "Release") and "Active Solution Platform" (e.g. "Any CPU", "x64", "x86", or "ARM") ensure the project that contains your interfaces and any of its dependencies have "Build" checked.
Upvotes: 0
Reputation: 20364
IRange
is in the namespace Wiggle.CategoryXMLExporter.IEntities
so you will need to reference that. Also make the Interface public
Upvotes: 0
Reputation: 239764
The default accessibility level top level classes and interfaces is internal
, not public
, so if these are in different projects, it won't be visible.
Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. Internal is the default if no access modifier is specified.
namespace Wiggle.CategoryXMLExporter.IEntities
{
public interface IRange
{
long ID { get; }
Dictionary<ILanguage, string> rangeNames { get; set; }
}
}
Upvotes: 2
Reputation: 3372
Your interface is not public try the following
public interface IRange
Upvotes: 4
Reputation: 39630
You need to add the namespace Wiggle.CategoryXMLExporter.IEntities
to your using clauses, because IRange
is defined there:
using Wiggle.CategoryXMLExporter.IEntities;
Also, if it's in a different assembly, you need to make it public
.
Upvotes: 0