Tag: typeinfo

传递VBA类的实时实例时,C#ITypeInfo.GetContainingTypeLib失败

所以我已经尝试在VBA类实例上调用ITypeInfo,虽然看起来很有希望但我想看看我是否可以获得对其包含项目的引用,类似于类型库。 我认为ITypeInfo.GetContainingTypeLib可能有用,但它抛出一个exception,表明VBA不会合作。 任何人都对VBA如何以不同于标准COM规范的方式做出任何想法? C#类库代码在这里。 注册COM interop并在AssemblyInfo.cs中设置COMVisible(true)以使其可从VBA访问。 下面给出的VBA客户端代码。 using System; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; namespace TypeLibraryInspector { [ComImport()] [Guid(“00020400-0000-0000-C000-000000000046”)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IDispatch { [PreserveSig] int GetTypeInfoCount(out int Count); [PreserveSig] int GetTypeInfo ( [MarshalAs(UnmanagedType.U4)] int iTInfo, [MarshalAs(UnmanagedType.U4)] int lcid, out System.Runtime.InteropServices.ComTypes.ITypeInfo typeInfo ); //void GetTypeInfo(int typeInfoIndex, int lcid, [MarshalAs(UnmanagedType.CustomMarshaler, // MarshalTypeRef = typeof(System.Runtime.InteropServices.CustomMarshalers.TypeToTypeInfoMarshaler))] out Type typeInfo); […]