Skip to content

Commit 33af1c8

Browse files
Add note about registering TLB (#41907)
* Add note about registering TLB --------- Co-authored-by: Genevieve Warren <[email protected]>
1 parent 60015ae commit 33af1c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/core/native-interop/expose-components-to-com.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,16 @@ The resulting output will have a `ProjectName.dll`, `ProjectName.deps.json`, `Pr
7373

7474
Open an elevated command prompt and run `regsvr32 ProjectName.comhost.dll`. That will register all of your exposed .NET objects with COM.
7575

76+
If you intend to [embed a type library (TLB)](#embed_tlb), it's recommended to also define functions using [`ComRegisterFunctionAttribute`](/dotnet/api/system.runtime.interopservices.comregisterfunctionattribute) and [`ComUnregisterFunctionAttribute`](/dotnet/api/system.runtime.interopservices.comunregisterfunctionattribute). These functions can be used to register and unregister the TLB for the COM server. For a complete example, see the [`OutOfProcCOM`](https://github.com/dotnet/samples/tree/main/core/extensions/OutOfProcCOM) sample.
77+
7678
## Enabling RegFree COM
7779

7880
1. Open the `.csproj` project file and add `<EnableRegFreeCom>true</EnableRegFreeCom>` inside a `<PropertyGroup></PropertyGroup>` tag.
7981
2. Build the project.
8082

8183
The resulting output will now also have a `ProjectName.X.manifest` file. This file is the side-by-side manifest for use with Registry-Free COM.
8284

83-
## Embedding type libraries in the COM host
85+
## <a name="embed_tlb"></a> Embedding type libraries in the COM host
8486

8587
Unlike in .NET Framework, there is no support in .NET Core or .NET 5+ for generating a [COM Type Library (TLB)](/windows/win32/midl/com-dcom-and-type-libraries#type-library) from a .NET assembly. The guidance is to either manually write an IDL file or a C/C++ header for the native declarations of the COM interfaces. If you decide to write an IDL file, you can compile it with the Visual C++ SDK's MIDL compiler to produce a TLB.
8688

0 commit comments

Comments
 (0)