Is it possible for two VS2008 C# class library projects to share a single namespace?
Posted
by jeah
on Stack Overflow
See other posts from Stack Overflow
or by jeah
Published on 2010-06-01T00:27:39Z
Indexed on
2010/06/01
0:33 UTC
Read the original article
Hit count: 252
I am trying to share a common namespace between two projects in a single solution. The projects are "Blueprint" and "Repositories". Blueprint contains Interfaces for the entire application and serves as a reference for the application structure.
In the Blueprint project, I have an interface with the following declaration:
namespace Application.Repositories{
public interface IRepository{
IEntity Get(Guid id);
}
}
In the Repositories project I have a class the following class:
namespace Application.Repositories{
public class STDRepository: IRepository
{
STD Get(Guid id){
return new SkankyExGirlfriendDataContext()
.FirstOrDefault<STD>(x=>x.DiseaseId == id);
}
}
}
However, this does not work. The Repositories project has a reference to the Blueprint project. I receive a VS error: "The type or namespace name 'IRepository' could not be found (are you missing a using directive or an assembly reference?) - Normally, this is easy to fix but adding a using statement doesn't make sense since they have the same namespace. I tried it anyway and it didn't work. The reference has been added, and without the line of code referencing that interface, both projects compile successfully. I am lost here. I have searched all over and have found nothing, so I am assuming that there is something fundamentally wrong with what I'm doing ... but I don't know what it is. So, I would appreciate some explanation or guidance as to how to fix this problem. I hope you guys can help.
Note: The reason I want to do it this way and keep the interfaces under the same namespace is because I want a solid project to keep all the interfaces in, in order to have a reference for the full architecture of the application. I have considered work arounds, such as putting all of the interfaces in the Blueprint.Application namespace instead of the application namespace. However, that would require me to write the using statement on virtually every page in the application...and my fingers get tired. Thanks again guys...
© Stack Overflow or respective owner