// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyKeyFile("COM.snk")] namespace COM { [Guid("0CA914A7-0B38-4501-AEAE-DE05A6C5A74E")] [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface IS { public int Iv { get; set; } public string Sv { get; set; } int Add(int a, int b); string Dup(string s); void M(); } [Guid("AB58747E-C79B-430C-871D-D24666B7A42D")] [ClassInterface(ClassInterfaceType.None)] [ProgId("COM.SDN")] public class S : IS { public int Iv { get; set; } public string Sv { get; set; } public int Add(int a, int b) { return a + b; } public string Dup(string s) { return s + s; } public void M() { Iv = Iv + 1; Sv = Sv + "X"; } } }