ASP.NET如何在web.config中添加程序集? [英] ASP.NET How to add assembly in web.config?

查看:77
本文介绍了ASP.NET如何在web.config中添加程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在另一个项目(projA)中制成的装配体.现在,我想将此dll导入另一个项目(projB).我怎样才能做到这一点?这是我尝试过的(在projB中).

I have a assembly made in another project (projA). Now I want to import this dll in another project (projB). How can I achieve this? This is what I've tried (in projB).

1将dll和我的项目放在同一目录中.(bin目录)

1 Put dll in same dir as my project. (the bin dir)

2在web.config中:

2 In web.config:

<assemblies>
  <add assembly="projA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>

这是我得到的错误:

无法加载文件或程序集'projA,版本= 1.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)

Could not load file or assembly 'projA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

关键是最终必须要动态添加程序集引用

The point is that eventually the assembly reference must me added dynamically

程序集(和名称空间)的名称存储在数据库中.物理组件(dll)已添加(通过安装)在projB中.现在projB中的代码必须从数据库中读取程序集名称,然后添加对安装时添加的dll的引用.

The name of the assembly (and namespace) are stored in the database. The physical assembly (dll) is added (by installation) in projB. Now the code in projB must read the assembly name from the database and then add a reference to the dll which is added by installation.

推荐答案

projB中是否存在所有projA的依赖项?通常,如果它们在相同的解决方案中,那么我只会将其从一个项目添加到另一个项目中.

Are all of projA's dependencies in projB? Usually I'd just add a reference from one project to another if they are in the same solution.

如果要动态添加程序集,则可能需要考虑服务参考.通过将projA的DLL转储到没有真正提供它可能需要的所有DLL的垃圾箱中,因此可以通过多种方式将事物捆绑在一起,以便可以跨系统理解对象,例如使用XML的Web服务来举一个常见的例子.

If you want to add an assembly dynamically then maybe a service reference maybe something to consider. By dumping in projA's DLL into the bin that doesn't really give all the DLLs that it may require, thus there are ways to tie things together so that objects can be understood across systems, like web services using XML to give a common example.

我回想有关动态添加装配的问题是,您从哪里得到装配,可以将该零件自动化成为projB的一部分,因为这实际上是解决此类问题的通用方法.

My question back about adding an assembly dynamically is where would you get it from and can that part be automated to be part of projB as that is really the general solution to this kind of problem.

如何获得projA的所有依赖关系?是否有可能获取它,使其不依赖于可能运行于系统上的其他DLL.这就是错误告诉您的信息,即还存在一些组装项目.请注意,如果使用了许多级别的依赖关系,则程序集的添加可以持续很长时间.

How could you get all of projA's dependencies? Is it possible to get it so that it doesn't depend on a bunch of other DLLs that may or may not be on the system that this is to run. That is what the error is telling you, that there exists some assembly projC that is also required. Note that this adding of assemblies can continue for a long time if there are many levels of dependencies used.

总结答案:为了将projA加载到一些新项目中,您需要参考什么?那是您的问题,如果不知道依赖项是什么样,就很难直接回答.

Summarizing the answer: What would you need to reference in order to load projA into some new project? That's your problem which without knowing what the dependencies look like is rather hard to answer directly.

这篇关于ASP.NET如何在web.config中添加程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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