我如何引用bin文件夹以外的组件在ASP.net应用程序? [英] How do I reference assemblies outside the bin folder in an ASP.net application?

查看:210
本文介绍了我如何引用bin文件夹以外的组件在ASP.net应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写在ASP.Net工作的XML Web服务。现在我需要引用某些组件趴在特定的文件夹如 C:\\ NotMy code 结果
我不要复制/该文件夹中的DLL副本不计其数到我的bin文件夹。

I've a working XML Web service written in ASP.Net. Now I need to reference certain assemblies lying in a specific folder e.g. c:\NotMyCode
I do not want to copy/duplicate zillions of dlls in that folder into my bin folder.

我试图保持 CopyLocal = FALSE 在Web服务被称为程序集。在一个FileNotFound例外大会结束了。
当我切换到 CopyLocal = TRUE ,引用的DLL被复制到bin文件夹..和它的作品。

I tried to keep the CopyLocal=false for the assemblies referred in the Web Service. That ended up in a FileNotFound exception for the assembly. When I switch to CopyLocal=true, the referenced DLLs are copied over to the bin folder.. and it works.

所以在这里我的问题是:
我如何引用不在于我的bin文件夹或它下面的子文件夹组件?我需要改变的地方一些安全策略文件?我想我是不是曾经想要做这样的事的第一人..所以我假设有人已经解决了这个问题。

So my question here is: How do I reference assemblies that do not lie in my bin folder or a subfolder beneath it ? Do I need to change some security policy files somewhere? I think I'm not the first person to ever want to do something like this.. so I'm assuming someone has already solved this problem.

(我试过冒充在IIS ASP.net配置面板管理员用户,但没有工作无论是。)

(I've tried impersonating an admin user in the IIS ASP.net configuration panel, but that didnt work either.)

更新:无法在GAC它安装任。举一个比喻,这个Web服务是给简化,以便第三方应用如StarTeam中。我不能(不应该有..不想..)该文件夹中的所有二进制文件复制到bin文件夹或安装到GAC

Update: Can't install it in the GAC either. To give an analogy, this web service is giving a simplified view to a third party app e.g. Starteam. I can't (shouldn't have to.. don't want to..) copy all the binaries in that folder to the bin folder or install it into the GAC

推荐答案

按照 MSDN文档

引用的应用程序的根目录以外的组件必须有强大的名称和必须要么使用&LT安装在全局程序集缓存或指定codeBase的> 元素。

Referenced assemblies outside the application's root directory must have strong names and must either be installed in the global assembly cache or specified using the <codeBase> element.

进一步佐证是<一个href=\"http://en.csharp-online.net/.NET%5FCLR%5FComponents%E2%80%94Resolving%5FNames%5Fto%5FLocations\">this文章,其中包括一个有用的图:

Further corroboration is in this article, which includes a helpful diagram:

因此​​,它可能会出现,你的运气了。下面是我想尝试:

So, it might appear that you're out of luck. Here's what I'd try:


  1. 创建应用程序根目录下的 NTFS交接点指向包含您的共享$ C $目录c。这是关键的一步。例如,在应用程序根目录,运行 LINKD共享code C:\\ NotMy code 。这使得&LT; yourappbase&GT; \\共享code 实际上成为一个别名 C:\\ NotMy code

  2. 告诉ASP.NET探测此路径组件,使用 &LT ;探测&GT; 元素,引用交接点共享code 。由于这是在你的应用程序的基础,它应该工作。另外,使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.appdomainsetup.privatebinpath.aspx\">AppDomainSetup.PrivateBinPath设置探查集路径。

  1. Create an NTFS junction point under your application base directory which points to the directory containing your shared code. This is the key step. For example, in your application base directory, run linkd SharedCode c:\NotMyCode. This makes <yourappbase>\SharedCode effectively be an alias for c:\NotMyCode.
  2. Tell ASP.NET to probe for assemblies in this path, using a <probing> element, referencing the junction point SharedCode. Since this is under your application base, it should work. Alternatively, use AppDomainSetup.PrivateBinPath to set the path probed for assemblies.

我很好奇,想看看,如果这个工程: - )

I'm quite curious to see if this works :-)

这篇关于我如何引用bin文件夹以外的组件在ASP.net应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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