using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace MyInterop { [Guid("03AD5D2D-2AFD-439f-8713-A4EC0705B4D9")] interface IMyDotNetInterface { void ShowCOMDialog(); } [ClassInterface(ClassInterfaceType.None)] [Guid("0490E147-F2D2-4909-A4B8-3533D2F264D0")] class MyDotNetClass : IMyDotNetInterface { // Need a public default constructor for COM Interop. public MyDotNetClass() {} public void ShowCOMDialog() { System.Windows.Forms.MessageBox.Show(“I am a" " Managed DotNET C# COM Object Dialog”); } } }
评论