在ASP.NET参考的DLL没有\\ BIN或GAC [英] Reference DLLs in ASP.NET without \Bin or GAC

查看:244
本文介绍了在ASP.NET参考的DLL没有\\ BIN或GAC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的源代码控制(颠覆)在ASP.NET项目。由于种种原因,我不想添加\\ Bin目录或其内容源的控制,所以我把它的svn:忽视。 DLL是一个Visual Studio构建过程中加载到这里,我可以用干净的目录中启动和/或删除这个目录中的所有内容,仍然有一个成功的构建。

I have an ASP.NET project under source control (Subversion). For various reasons, I don't want to add the \Bin directory or its contents to source control, so I have it svn:ignored. DLLs are loaded into here during a Visual Studio build, and I can start with a clean directory and/or delete all the contents of this directory and still have a successful build.

有我引用code列入项目有两种方式:

There are two ways that I reference code for inclusion in the project:


  1. 在的Web.config元素//configuration/configSections/system.web/compilation/assemblies。我可以 <添加> 任何DLL这是在GAC这种方式。我这样做对所有的系统DLL的。

  2. 在VS解决方案,有一个设置在<一个href=\"http://msdn.microsoft.com/en-us/library/ez524kew.aspx\">Project/ProjectSection/ProjectReferences这让我在解决方案中指定的其他项目包括引用。

  1. In the Web.config element //configuration/configSections/system.web/compilation/assemblies. I can <add> any DLL that's in the GAC this way. I do this for all of the System dlls.
  2. In the VS Solution, there's a setting at Project/ProjectSection/ProjectReferences that lets me specify included references to other projects in the solution.

(注意,这是比非网络项目,其中的所有的外部依赖性引用存储在项目文件不同。还有对VS Web项目没有项目文件,所以他们必须存储在某个地方别的。)

(Note that this is different than non-web projects, where all references to external dependencies are stored in the project file. There's no project file for VS web projects so they have to be stored somewhere else.)

现在我有一个第三方编译的DLL,我想在项目中包含。不幸的是,没有我发现引用选择似乎为我工作:

Now I have a 3rd-party compiled DLL that I'd like to include in the project. Unfortunately, none of the referencing options I've found seem to work for me:


  1. 通过web.config中/的System.Web /编译/组件引用不起作用,除非该DLL在GAC存在;你不能用一个文件路径。我真的想避免GAC依赖,因为它意味着一个额外的步骤,使每一个目标机器上该项目的工作。

  2. 我还没有找到一种方法,包括在解决像我可以与项目引用做一个文件引用。

  3. 任我使用VS的添加引用对话框中添加一个文件引用,它只是复制DLL到\\ bin目录。这不会对我的工作我的\\ Bin目录是不是跨系统持久的。

有另一种办法可以让一个DLL文件的引用,并坚持下去?

Is there another way I can make a reference to a DLL file and have it stick?

推荐答案

如果你正在做的任何一种严重的发展中,我会建议从网站项目和一个Web项目,因为这可以让你向外流动来管理这几样依赖关系在整个解决方案的方式相同。

If you are doing any kind of serious development I would recommend migrating away from the web site project and to a web project as this allows you to manage these kind of dependencies in the same manner across your entire solution.

但是,假设你不能做到这一点,把所有你需要从Web项目中引用到一个文件夹中某处的组件(如LIB \\ WEB)和pre-生成事件添加到您的Web项目拷贝该文件夹的内容到Web目录的bin文件夹。现在,只要你想依赖添加到您的Web项目可以在lib \\ Web文件夹删除它,并添加引用。只要你建立,所有被引用的组件将被复制到该文件夹​​,所以你可以删除bin文件夹或做一个干净的检出,并没有任何问题。

However, assuming you cannot do that, place all of the assemblies that you need to reference from the web project into a folder somewhere ( e.g. lib\web ) and add a pre-build event to your web project that copies the content of that folder into the bin folder of the web directory. Now whenever you want to add a dependency to your web project you can drop it in the lib\web folder, and add the reference. Whenever you build, all of the referenced assemblies will be copied into the folder so you can delete the bin folder or do a clean checkout and not have any issue.

这篇关于在ASP.NET参考的DLL没有\\ BIN或GAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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