Adding Project reference programmatically

╄→尐↘猪︶ㄣ 提交于 2019-12-06 04:29:29

问题


Basically, after read a couple links, i tried the above code:

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 hard-coded on purpouse, since im still testing how to achieve it.

Though it would act like if i did Project folder -> References -> Add reference -> Pick one, manually (compile time)

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


回答1:


I think that you forget to save modified project , you have to invoke Save at the end



来源:https://stackoverflow.com/questions/4820763/adding-project-reference-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!