以编程方式添加项目参考 [英] Adding Project reference programmatically

查看:60
本文介绍了以编程方式添加项目参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,在阅读了几个链接之后,我尝试了上面的代码:

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)

但是在加载解决方案之后,BLL项目不包含任何对DAL项目的永久引用.

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

推荐答案

我认为您忘记保存已修改的项目,必须在最后调用Save

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

这篇关于以编程方式添加项目参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆