• <legend id='deWwj'><style id='deWwj'><dir id='deWwj'><q id='deWwj'></q></dir></style></legend>

      1. <tfoot id='deWwj'></tfoot>
      2. <i id='deWwj'><tr id='deWwj'><dt id='deWwj'><q id='deWwj'><span id='deWwj'><b id='deWwj'><form id='deWwj'><ins id='deWwj'></ins><ul id='deWwj'></ul><sub id='deWwj'></sub></form><legend id='deWwj'></legend><bdo id='deWwj'><pre id='deWwj'><center id='deWwj'></center></pre></bdo></b><th id='deWwj'></th></span></q></dt></tr></i><div id='deWwj'><tfoot id='deWwj'></tfoot><dl id='deWwj'><fieldset id='deWwj'></fieldset></dl></div>

        <small id='deWwj'></small><noframes id='deWwj'>

        • <bdo id='deWwj'></bdo><ul id='deWwj'></ul>

        来自 ASP.NET 的免注册 COM?

        时间:2023-07-26
          <bdo id='7i9O5'></bdo><ul id='7i9O5'></ul>

          <small id='7i9O5'></small><noframes id='7i9O5'>

          • <i id='7i9O5'><tr id='7i9O5'><dt id='7i9O5'><q id='7i9O5'><span id='7i9O5'><b id='7i9O5'><form id='7i9O5'><ins id='7i9O5'></ins><ul id='7i9O5'></ul><sub id='7i9O5'></sub></form><legend id='7i9O5'></legend><bdo id='7i9O5'><pre id='7i9O5'><center id='7i9O5'></center></pre></bdo></b><th id='7i9O5'></th></span></q></dt></tr></i><div id='7i9O5'><tfoot id='7i9O5'></tfoot><dl id='7i9O5'><fieldset id='7i9O5'></fieldset></dl></div>

            1. <legend id='7i9O5'><style id='7i9O5'><dir id='7i9O5'><q id='7i9O5'></q></dir></style></legend>
                  <tbody id='7i9O5'></tbody>

                <tfoot id='7i9O5'></tfoot>
                  本文介绍了来自 ASP.NET 的免注册 COM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Windows 允许使用 COM 对象无需注册 COM dll.

                  Windows allows use of a COM object without having to register the COM dll.

                  机制是在应用程序的清单中包含一个依赖程序集":

                  The mechanism is to include a "dependent assembly" in the application's manifest:

                  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(如果您使用的是外部清单;也可以嵌入在 RT_MANIFEST 资源中)
                  • Contoso.Frobber.manifest(COM DLL 清单)
                  • confrob.dll(包含我们要使用的 COM 类的 dll)
                  • MyProgram.exe
                  • MyProgram.exe.manifest (if you're using an external manifest; could also be embedded at RT_MANIFEST resource)
                  • Contoso.Frobber.manifest (the COM DLL manifest)
                  • confrob.dll (the dll containing the COM classes we want to use)

                  COM dll 的程序集清单包含:

                  with the COM dll's assembly manifest containing:

                  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>
                  

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

                  Excellent. i can now use a COM object from a (native or .NET) executable without having to register the COM object.

                  现在我想使用 一个 ASP.NET 网站中的 COM 对象,而不注册 COM 对象.

                  Now i want to use a COM object from an ASP.NET web-site, without registering the COM object.

                  可能吗?

                  Windows 还允许 exe 调用 .NET 库,而无需安装将 .NET 程序集放入全局程序集缓存中.

                  Windows also allows an exe to call a .NET library, without having to install the .NET assembly into the Global Assembly Cache.

                  推荐答案

                  虽然我现在无法测试它,但我很确定这可行:

                  Although I can't test it right now I am pretty sure that this works:

                  如果 DLL 的清单是外部的,则在通过 LoadLibrary 加载 DLL 时通常会忽略它(根据 MSDN).如果清单被嵌入到 DLL 中,它通常会被尊重.

                  IF the manifest for a DLL is external it will usually be ignored when the DLL is loaded via LoadLibrary (according to MSDN). IF the manifest is embedded into the DLL it is usually honored.

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

                  Embed the manifest into the ASP.NET application (i.e. code-behind DLL) - for some ways on how to do this see here and here and here.

                  更新 - 根据评论:

                  以上是一种解决方法,因为没有通用的方法来做到这一点(隔离),至少 ASP.NET 创建者并没有打算这样做 - 例如,上述解决方法在以下情况下不起作用应用程序无法编译为 DLL...

                  The above is a workaround as there is no general way to do this (isolation), at least the ASP.NET creators haven't intended this to be possible - for example the above workaround won't work in cases where the application does not compile to a DLL...

                  这篇关于来自 ASP.NET 的免注册 COM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:COM 异常 - TYPE_E_CANTLOADLIBRARY? 下一篇:使用 C#/托管代码为免注册 COM 互操作设置 DLL

                  相关文章

                      <i id='2OZ5V'><tr id='2OZ5V'><dt id='2OZ5V'><q id='2OZ5V'><span id='2OZ5V'><b id='2OZ5V'><form id='2OZ5V'><ins id='2OZ5V'></ins><ul id='2OZ5V'></ul><sub id='2OZ5V'></sub></form><legend id='2OZ5V'></legend><bdo id='2OZ5V'><pre id='2OZ5V'><center id='2OZ5V'></center></pre></bdo></b><th id='2OZ5V'></th></span></q></dt></tr></i><div id='2OZ5V'><tfoot id='2OZ5V'></tfoot><dl id='2OZ5V'><fieldset id='2OZ5V'></fieldset></dl></div>

                      <small id='2OZ5V'></small><noframes id='2OZ5V'>

                      <tfoot id='2OZ5V'></tfoot>
                    1. <legend id='2OZ5V'><style id='2OZ5V'><dir id='2OZ5V'><q id='2OZ5V'></q></dir></style></legend>
                        <bdo id='2OZ5V'></bdo><ul id='2OZ5V'></ul>