반응형

https://learn.microsoft.com/en-us/dotnet/core/native-interop/expose-components-to-com

 

Exposing .NET Core components to COM

This tutorial shows you how to expose a class to COM from .NET Core. You generate a COM server and a side-by-side server manifest for Registry-Free COM.

learn.microsoft.com

 

using System.Runtime.InteropServices;

namespace Logger
{
    [ComVisible(true)]
    [Guid("B64550B8-00EA-4053-8945-B9761F2893C1")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IServer
    {
        void Write();
    }

    [ComVisible(true)]
    [Guid("B64550B8-00EA-4053-8945-B9761F2893C1")]
    public class Logger : IServer
    {
        public void Write()
        {
            throw new NotImplementedException();
        }
    }
}

 

regsvr32 Logger.comhost.dll

반응형

+ Recent posts