使用反射从 Web 服务加载远程程序集

发布于 2024-08-29 07:15:47 字数 463 浏览 1 评论 0原文

我在 Web 服务中使用 Assembly.LoadFrom 从网站加载程序集。但问题是它位于虚拟目录中,并且 server.mappath 解析像 \share\mydll.dll 这样的 url,并且 loadform 方法失败。有没有办法从远程位置引用dll?

我尝试再次传递网址(http://localhost/downloadable/mydll.dll)它得到了 “无法加载文件或程序集 'http://localhost/downloadable/mydll.dll' 或一个其依赖项的 HTTP 下载已被禁用(HRESULT 异常:0x80131048)”

I am using Assembly.LoadFrom within a web service to load assemblies from a web site. but the problem is it is in the virutal directory and the server.mappath parses the url like \share\mydll.dll and loadform method failed. Is there anyway to reference dll from the remote location?

I've tried passing the url (http://localhost/downloadable/mydll.dll) and again it got
"Could not load file or assembly 'http://localhost/downloadable/mydll.dll' or one of its dependencies. HTTP download of assemblies has been disabled for this appdomain. (Exception from HRESULT: 0x80131048)"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与君绝 2024-09-05 07:15:47

您可以使用 WebClient 类通过 Internet 下载程序集:

using(var wc = new WebClient()) {
    Assembly.Load(wc.DownloadData(url));

You can use the WebClient class to download an assembly over the internet:

using(var wc = new WebClient()) {
    Assembly.Load(wc.DownloadData(url));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文