RegAsm - / codebase选项何时适用? [英] RegAsm - When is the /codebase option applicable?

查看:3026
本文介绍了RegAsm - / codebase选项何时适用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C#编写的COM可见的DLL,我想在VB6应用程序中使用。我有两个主要的用例DLL和我想知道什么时候 / codebase 选项是适用的,当它更好地注册在GAC。





ol>
  • 该DLL将被加载到另一个开发人员PC上,需要在 Project>参考


  • 当VB6应用程序发布时,DLL将被加载到生产机器上





  • 有关使用 / codebase 会有所帮助。



    谢谢。

    解决方案

    / codebase选项与使用Regsvr32.exe注册COM服务器的方法完全相同。您必须选择DLL的特定位置,并将该位置的路径写入注册表。这是有风险,COM服务器有一个强大的DLL地狱问题,因为他们的注册是机器范围。当您更新该DLL时,使用该服务器的任何应用程序将受到影响。



    .NET通过能够存储多个版本而改进了这一点,这通常不是一个很好的方法,这通常会打破一个没有重新编译使用更新的服务器的应用程序。的DLL,由他们的[AssemblyVersion]选择。精确等价的Windows并行缓存,托管程序集的GAC。所以没有重建的旧应用程序将继续运行不受影响,仍然能够使用旧的DLL。这是一个好方法。



    在忙于开发服务器时,建议使用/ codebase。您可以跳过在GAC中注册DLL的额外必需步骤。忘记这样做是痛苦的,您的更改似乎不工作,因为测试应用程序将加载旧版本。当您使用/ codebase时,Regasm会显示警告,警告您有关DLL地狱潜力,您可以忽略它。



    当您让Visual Studio负责注册Project + Properties,Build选项卡,Register for COM interop选项,那么您将得到与Regasm / codebase / tlb完全相同的



    -free COM)是最好的办法。它允许您将COM服务器的副本存储在与客户端程序相同的目录中,而不必对其进行注册。然而,这需要修复客户端程序,如果你没有对客户端应用程序的任何控制,或者如果它是那种其他人喜欢的应用程序混乱,困难。例如Microsoft Office应用程序。


    I have a COM-visible DLL written in C# that I would like to use in a VB6 application. I have two main use cases of the DLL and am wondering when the /codebase option is applicable and when it is better to register in the GAC.


    Use cases:

    1. The DLL will be loaded onto another developers PC and needs to be accessible to the VB6 IDE under the Project > References menu

    2. The DLL will be loaded onto production machines when the VB6 application is released


    Any information on the appropriate use of the /codebase would be helpful.

    Thanks.

    解决方案

    The /codebase option is the exact equivalent of the way you used to register COM servers with Regsvr32.exe. You'll have to pick a specific location for the DLL and the path to that location is written to the registry. That's risky, COM servers have a strong DLL Hell problem since their registration is machine-wide. When you update that DLL then any application that uses the server will be affected. Not often in a good way, this very often breaks an app that was not recompiled to use the updated server.

    .NET improves on that by being able to store multiple versions of a DLL as selected by their [AssemblyVersion]. The exact equivalent of the Windows side-by-side cache, the GAC for managed assemblies. So old apps that were not rebuilt will continue to run unaffected, still being able to use the old DLL. That's a good way.

    Using /codebase is advisable when you are busy developing the server. You can skip the extra required step that registers the DLL in the GAC. Forgetting to do so is painful, your changes won't seem to work because the test app will load the old version. Regasm will display a warning when you use /codebase, warning you about the DLL Hell potential, you can ignore it.

    When you let Visual Studio take care of the registration with the Project + Properties, Build tab, "Register for COM interop" option then you get the exact equivalent of Regasm /codebase /tlb.

    Using Isolated COM (aka "registry-free COM") is the best way. It lets you store a copy of the COM server in the same directory as the client program and you don't have to register it at all. That however requires tinkering with the client program, difficult if you don't have any control over the client app or if it is the kind of app that other people like to mess with. Microsoft Office apps for example.

    这篇关于RegAsm - / codebase选项何时适用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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