Adding a project link

Basically, after reading a couple of links, I tried the code above:

foreach (EnvDTE.Project proj in soln.Projects)
        {
            if (proj.Name == "BLL")
            {
                VSLangProj.VSProject vsproj = (VSLangProj.VSProject)proj.Object;                    
                vsproj.References.Add(@"C:\Teste\DAL\bin\Debug\DAL.dll");                    
            }
        }

All paths, project names, are hardcoded to purpouse, since im still testing how to achieve it.

Although it will act as if I did a Project folder → Links → Add a link → Choose one manually (compilation time)

but after loading the solution, the BLL project did not contain any PERMANENT reference to the DAL project.

+3
source share
1 answer

I think you forgot to save the modified project, you need to call Save at the end

+1
source

Source: https://habr.com/ru/post/1788296/


All Articles