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

      <small id='9ZyeC'></small><noframes id='9ZyeC'>

        <tfoot id='9ZyeC'></tfoot>
        <legend id='9ZyeC'><style id='9ZyeC'><dir id='9ZyeC'><q id='9ZyeC'></q></dir></style></legend>

        • <bdo id='9ZyeC'></bdo><ul id='9ZyeC'></ul>
      1. 为什么需要在 c# 中使用 DispId 注释?

        Why would you need to use the DispId annotation in c#?(为什么需要在 c# 中使用 DispId 注释?)

            <bdo id='9WsZb'></bdo><ul id='9WsZb'></ul>
          • <small id='9WsZb'></small><noframes id='9WsZb'>

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

                1. 本文介绍了为什么需要在 c# 中使用 DispId 注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  例如

                  public interface IWMPSettings
                  
                          [DispId(101)]
                          bool autoStart { get; set; }
                          [DispId(102)]
                          int balance { get; set; }
                  

                  它有用还是只是为编译器自动生成的?什么是 COM 调度标识符?在 .NET 上下文中何时需要它们?

                  is it useful or is it just auto-generated for compiler? What are COM dispatch identifiers for and when would they be needed in a .NET context?

                  推荐答案

                  简而言之,是的,它很有用,但仅适用于 COM 调度:

                  In short, yes it is useful, but only for COM dispatch:

                  DispIdAttribute(来自 MSDN):

                  指定方法、字段或属性的 COM 调度标识符 (DISPID).

                  Specifies the COM dispatch identifier (DISPID) of a method, field, or property.

                  此属性包含它所描述的方法、字段或属性的 DISPID.唯一 DISPID 通常由公共语言运行时分配,但您可以使用此属性将特定 DISPID 分配给方法.导入类型库时,此属性适用于所有分配了 DISPID 的方法.这确保了相同方法的任何托管实现在暴露给 COM 时都保留相同的 DISPID.

                  This attribute contains the DISPID for the method, field, or property it describes. Unique DISPIDs are typically assigned by the common language runtime, but you can use this attribute to assign a specific DISPID to a method. When importing a type library, this attribute is applied to all methods with assigned DISPIDs. This ensures that any managed implementation of the same method retains the same DISPID if exposed to COM.

                  这篇关于为什么需要在 c# 中使用 DispId 注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)

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

                            <tfoot id='cyS4h'></tfoot>
                          1. <small id='cyS4h'></small><noframes id='cyS4h'>