gpt4 book ai didi

asp.net - 来自 ASP.NET 的免注册 COM?

转载 作者:行者123 更新时间:2023-12-04 05:58:57 24 4
gpt4 key购买 nike

Windows 允许使用 COM 对象 without having to register the COM dll .

该机制是在应用程序的 list 中包含一个“依赖程序集”:

MyProgram.exe.manifest

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity type="win32" name="myapp.exe" version="1.2.3.4" />
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Contoso.Frobber" version="5.1.81.4" />
</dependentAssembly>
</dependency>
</assembly>

然后您的文件夹包含:

  • MyProgram.exe
  • MyProgram.exe.manifest(如果您使用的是外部 list ;也可以嵌入到 RT_MANIFEST 资源中)
  • Contoso.Frobber.manifest(COM DLL list )
  • confrob.dll(包含我们要使用的 COM 类的 dll)

COM dll 的程序集 list 包含:

Contoso.Frobber.manifest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

<assemblyIdentity type="win32" name="Contoso.Frobber" version="1.0.0.0" />

<file name = "confrob.dll">

<comClass
progid="Frobber.Gizmo"
clsid="{00028C00-0000-0000-0000-000000000046}"
description="Gizmo Frobber by Contoso"
threadingModel = "Apartment" />

<typelib
tlbid="{00028C01-0000-0000-0000-000000000046}"
version="1.0"
helpdir=""/>
</file>
</assembly>

非常好。我现在可以使用来自( native 或 .NET)可执行文件的 COM 对象,而无需注册 COM 对象。

现在我想使用来自 ASP.NET 网站 的 COM 对象,而不注册 COM 对象。

可能吗?


奖金聊天

Windows 还允许 exe to call a .NET library, without having to install the .NET assembly into the Global Assembly Cache .

最佳答案

虽然我现在不能测试它,但我很确定它能工作:

如果 DLL 的 list 是外部的,当通过 LoadLibrary(根据 MSDN)加载 DLL 时,通常会忽略它。如果 list 嵌入到 DLL 中,它通常会被接受。

将 list 嵌入到 ASP.NET 应用程序(即代码隐藏 DLL)中 - 有关如何执行此操作的一些方法,请参见 hereherehere .

更新 - 根据评论:

以上是一种解决方法,因为没有通用的方法来执行此操作(隔离),至少 ASP.NET 的创建者并没有打算让这成为可能 - 例如,以上解决方法在以下情况下不起作用应用程序未编译为 DLL...

关于asp.net - 来自 ASP.NET 的免注册 COM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9162817/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com