Builds upon Out-of-process COM Server Demo but avoids risks of manually maintaining IDL files.
- Contract library (NetCoreOop.Common in this sample) has
AssemblyInfo.cs
withGuidAttribute
to specify tlb id. (Doesn't appear to be able to be specified incsproj
) - Interfaces and structs in contract library are marked
ComVisible(true)
and have aGuid
assigned to them dscom
is added to the contract library csproj to export a tlb- Add references to contract library as neccesary for managed callers. Add imports to the exported tlb for unmanaged callers.
- Create a server, class factory, and registration
- Create a client, call to
CoCreateInstance
- Register the tlb with
dscom
or some other means (a setup project)PS NetCoreOop.Common\bin\Debug\net7.0-windows> dscom tlbregister (dir .\NetCoreOop.Common.tlb).FullName
in an administrator terminal
Note: You must providedscom
the full path the TLB - Optional: register the Server CLSID to allow COM to start the server if it is not already running
- Run the server
- Run the client