EnvDTE - Adding a reference to a project
It was confusing to see a property named "Object" on EndDTE.Project class (which returns an object of type System.Object), especially when the tooltip didnt provide any useful information. (It's actual type is a ComObject) Anyway, actually it returns an object of type VSLangProj.VSProject (assuming you have a reference to VSLangProj). I was just trying to add a reference to my project within the VS Package I was working on and that class gives me the functionality I was looking for. Long story short, in order to add a reference (GAC) programmatically to your project here's what needs to be done:
private void AddReference(EnvDTE.Project proj) {
VSLangProj.
VSProject vsProject = (VSLangProj.VSProject)proj.Object;
vsProject.References.Add(
"MyLibrary");
}