Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
COM-在ATL C和x2B中使用IEnumerable+;项目 < >我在C++的COM服务器中使用了一个C ixcom CODLL,它实现了IdEnable用于迭代集合。_Com - Fatal编程技术网

COM-在ATL C和x2B中使用IEnumerable+;项目 < >我在C++的COM服务器中使用了一个C ixcom CODLL,它实现了IdEnable用于迭代集合。

COM-在ATL C和x2B中使用IEnumerable+;项目 < >我在C++的COM服务器中使用了一个C ixcom CODLL,它实现了IdEnable用于迭代集合。,com,Com,如何在本机代码中指定要从C#Dll的实例对象访问IEnumerable->GetEnumerator()方法?是否需要导入一些*.TLB以便查看C++项目中的InEdableTo界面?我看到的Ienumerable接口是由mscorelib.dll定义的 我是否可以进一步向我的客户机公开IEnumerable接口(在我的C+项目的IDL中定义)。举个例子会有帮助 它由类型库导出器System.Collections.IEnumerator[ComVisible]自动转换,并转换为IEnumVAR

如何在本机代码中指定要从C#Dll的实例对象访问IEnumerable->GetEnumerator()方法?是否需要导入一些*.TLB以便查看C++项目中的InEdableTo界面?我看到的Ienumerable接口是由mscorelib.dll定义的

  • 我是否可以进一步向我的客户机公开IEnumerable接口(在我的C+项目的IDL中定义)。举个例子会有帮助


  • 它由类型库导出器System.Collections.IEnumerator[ComVisible]自动转换,并转换为IEnumVARIANT。例如:

    using System;
    using System.Collections;
    using System.Runtime.InteropServices;
    
    [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface IExample {
        IEnumerator GetEnumerator();
    
    }
    [ComVisible(true), ClassInterface(ClassInterfaceType.None)]
    public class Example : IExample {
        public IEnumerator GetEnumerator() {
            yield return 42;
        }
    }
    
    转换为此类型库片段:

    // TLib :     // TLib : mscorlib.dll : {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
    importlib("mscorlib.tlb");
    // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");
    
    // Forward declare all types defined in this typelib
    interface IExample;
    
    [
      odl,
      uuid(9B046FDE-9234-3DE7-B055-DADE8F7B4A99),
      version(1.0),
      dual,
      oleautomation,
      custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "IExample")    
    
    ]
    interface IExample : IDispatch {
        [id(0xfffffffc)]
        HRESULT GetEnumerator([out, retval] IEnumVARIANT** pRetVal);
    };
    

    请注意mscorlib.tlb的importlib指令,它出现在c:\windows\microsoft.net\framework\v2.0.50727中,由编译器在没有帮助的情况下找到。

    它由类型库导出器System.Collections.IEnumerator自动翻译为[ComVisible],并被翻译为IEnumVARIANT。例如:

    using System;
    using System.Collections;
    using System.Runtime.InteropServices;
    
    [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface IExample {
        IEnumerator GetEnumerator();
    
    }
    [ComVisible(true), ClassInterface(ClassInterfaceType.None)]
    public class Example : IExample {
        public IEnumerator GetEnumerator() {
            yield return 42;
        }
    }
    
    转换为此类型库片段:

    // TLib :     // TLib : mscorlib.dll : {BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}
    importlib("mscorlib.tlb");
    // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");
    
    // Forward declare all types defined in this typelib
    interface IExample;
    
    [
      odl,
      uuid(9B046FDE-9234-3DE7-B055-DADE8F7B4A99),
      version(1.0),
      dual,
      oleautomation,
      custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "IExample")    
    
    ]
    interface IExample : IDispatch {
        [id(0xfffffffc)]
        HRESULT GetEnumerator([out, retval] IEnumVARIANT** pRetVal);
    };
    

    请注意mscorlib.tlb的importlib指令,它出现在c:\windows\microsoft.net\framework\v2.0.50727中,由编译器在没有帮助的情况下找到。

    你是对的,我想了一段时间,我可以说我的COM对象也实现了IEnumerable(因此它们将实现功能接口和IEnumerable)你是对的,我想了一段时间,我可以说我的COM对象也实现了IEnumerable(因此它们将实现功能接口和IEnumerable)