1. <small id='ddk4f'></small><noframes id='ddk4f'>

        <legend id='ddk4f'><style id='ddk4f'><dir id='ddk4f'><q id='ddk4f'></q></dir></style></legend><tfoot id='ddk4f'></tfoot>

          <bdo id='ddk4f'></bdo><ul id='ddk4f'></ul>

        <i id='ddk4f'><tr id='ddk4f'><dt id='ddk4f'><q id='ddk4f'><span id='ddk4f'><b id='ddk4f'><form id='ddk4f'><ins id='ddk4f'></ins><ul id='ddk4f'></ul><sub id='ddk4f'></sub></form><legend id='ddk4f'></legend><bdo id='ddk4f'><pre id='ddk4f'><center id='ddk4f'></center></pre></bdo></b><th id='ddk4f'></th></span></q></dt></tr></i><div id='ddk4f'><tfoot id='ddk4f'></tfoot><dl id='ddk4f'><fieldset id='ddk4f'></fieldset></dl></div>
      2. 通过 COM 互操作公开索引器/默认属性

        时间:2023-10-06
          <tbody id='DYwm1'></tbody>
            <bdo id='DYwm1'></bdo><ul id='DYwm1'></ul>

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

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

            <tfoot id='DYwm1'></tfoot>

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

                1. 本文介绍了通过 COM 互操作公开索引器/默认属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试用 C# 编写一个组件,供经典 ASP 使用,它允许我访问组件的索引器(也称为默认属性).

                  I am attempting to write a component in C# to be consumed by classic ASP that allows me to access the indexer of the component (aka default property).

                  例如:
                  C# 组件:

                  For example:
                  C# component:

                  public class MyCollection {
                      public string this[string key] {
                          get { /* return the value associated with key */ }
                      }
                  
                      public void Add(string key, string value) {
                          /* add a new element */
                      }
                  }
                  

                  ASP 消费者:

                  Dim collection
                  Set collection = Server.CreateObject("MyCollection ")
                  Call collection.Add("key", "value")
                  Response.Write(collection("key")) ' should print "value"
                  

                  是否有我需要设置的属性,我需要实现接口还是需要做其他事情?或者这不能通过 COM 互操作实现?

                  Is there an attribute I need to set, do I need to implement an interface or do I need to do something else? Or this not possible via COM Interop?

                  目的是我试图为一些内置的 ASP 对象(例如 Request)创建测试替身,这些对象使用使用这些默认属性的集合(例如 Request.QueryString("key")).欢迎提供其他建议.

                  The purpose is that I am attempting to create test doubles for some of the built-in ASP objects such as Request, which make use of collections using these default properties (such as Request.QueryString("key")). Alternative suggestions are welcome.

                  更新:我问了一个后续问题:为什么我的 .NET 组件上的索引器并不总是可以从 VBScript 访问?

                  Update: I asked a follow-up question: Why is the indexer on my .NET component not always accessible from VBScript?

                  推荐答案

                  尝试将属性的 DispId 属性设置为 0,如 MSDN 文档.

                  Try setting the DispId attribute of the property to be 0, as described here in the MSDN documentation.

                  这篇关于通过 COM 互操作公开索引器/默认属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                2. <legend id='ja6Ne'><style id='ja6Ne'><dir id='ja6Ne'><q id='ja6Ne'></q></dir></style></legend>

                      <tbody id='ja6Ne'></tbody>

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

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