Reputation: 805
I have a few folders inside my interfaces sub project. I can "see" two of them, but not the third. The reference is obviously added, otherwise I wouldn't be able to "see" or access any of the namespaces inside the sub project.
Any ideas what could be wrong here?
File ProjectContext.cs from project Project.Data needs to inherit an interface from another project Project.Interfaces.
Project.Data has a reference to Project.Interfaces.
The interface is located in Project.Interfaces\Data\IProjectContext.cs.
For whatever reason the Data directory is not visible in the autocomplete provided by Visual Studio. I am not able to access the Project.Interfaces.Data namespace.
project.json
from Project.Data
{
"version": "1.0.0-*",
"dependencies": {
"Project.Interfaces": "1.0.0-*",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"NETStandard.Library": "1.6.1",
"System.ComponentModel.Annotations": "4.3.0"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}
ProjectContext.cs
namespace Project.Data
{
public class ProjectContext : DbContext
{
public ProjectContext(DbContextOptions<ProjectContext> options) : base(options)
{
Database.EnsureCreated();
}
}
}
IProjectContext.cs
namespace Project.Interfaces.Data
{
interface IProjectContext
{
}
}
Upvotes: 0
Views: 2408
Reputation: 9561
The default access modifier in c# is internal
. Since your IProjectContext
interface doesn't have a modifier, it is assumed to be internal
and so not available to other projects.
Make the interface public and you will be able to reference it in other projects.
namespace Project.Interfaces.Data
{
public interface IProjectContext
{
}
}
If you want the interface to be internal for API reasons, you can add an InternalsVisibleTo
line to the AssemblyInfo.cs
file in your Project.Interfaces
project:
[assembly: InternalsVisibleTo("Project.Data")]
Upvotes: 3
Reputation: 6105
It seems that you have the impression that the folder structure defines the namespaces. They are in fact totally irrelevant (although it's a good convention to follow). Check your files inside the folders that are missing, and change the namespace definition in the code, presumably you want this to match your folder structure.
Another thing to look for is whether the classes /interfaces are public.
Upvotes: 3