Getting the helpstring attribute applied to C# properties exposed via COM interfaces

后端 未结 1 1569
轮回少年
轮回少年 2020-12-16 22:45

I\'m currently working on a library that\'s to be exposed to COM for use in a legacy project that\'s being upgraded. I\'m creating interfaces that are to be exposed, and the

1条回答
  •  半阙折子戏
    2020-12-16 23:10

    You have to put the attribute on the getter and setter individually. Like this:

    using System;
    using System.ComponentModel;
    using System.Runtime.InteropServices;
    
    namespace ClassLibrary1 {
        [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)]
        public interface IFoo {
            int property {
                [Description("prop")]
                get;
                [Description("prop")]
                set;
            }
        }
    }
    

    Repeating the description is clumsy, but also required in IDL.

    0 讨论(0)
提交回复
热议问题