Background and Motivation
.NET core does not support generating Type libraries for COM visible dlls. Instead it creates a seperate .comhost.dll file that is actually used by other com components.
It is possible to write your own IDL files and generate a Type library from them using midl. However there is currently no way to embed the type library inside the comhost dll.
This issue was created after discussion with @AaronRobinsonMSFT on #3740
As far as I could see, prerequesits in the comhost were already implemented with #50986
Proposed API / Usage Example
Optimally I would be able to include the idl file/s with a corresponding Build Action.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<EnableComHosting>true</EnableComHosting>
</PropertyGroup>
<ItemGroup>
+ <ComHostTypeLibrary Include="MyTypes.idl" />
</ItemGroup>
</Project>
This would autmatically compile the idl and add it as a type library to the comhost dll.
Alternative Designs
Specify the Idl file in the PropertyGroup
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<EnableComHosting>true</EnableComHosting>
+ <ComHostTypeLibrary>MyTypes.idl<ComHostTypeLibrary />
</PropertyGroup>
</Project>
Specify the tlb file in the PropertyGroup. This would require us to compile the idl ourselves
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<EnableComHosting>true</EnableComHosting>
+ <ComHostTypeLibrary>MyTypes.tlb<ComHostTypeLibrary />
</PropertyGroup>
</Project>
Risks
None that I am aware of.
Background and Motivation
.NET core does not support generating Type libraries for COM visible dlls. Instead it creates a seperate .comhost.dll file that is actually used by other com components.
It is possible to write your own IDL files and generate a Type library from them using midl. However there is currently no way to embed the type library inside the comhost dll.
This issue was created after discussion with @AaronRobinsonMSFT on #3740
As far as I could see, prerequesits in the comhost were already implemented with #50986
Proposed API / Usage Example
Optimally I would be able to include the idl file/s with a corresponding Build Action.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net5.0-windows</TargetFramework> <EnableComHosting>true</EnableComHosting> </PropertyGroup> <ItemGroup> + <ComHostTypeLibrary Include="MyTypes.idl" /> </ItemGroup> </Project>This would autmatically compile the idl and add it as a type library to the comhost dll.
Alternative Designs
Specify the Idl file in the PropertyGroup
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net5.0-windows</TargetFramework> <EnableComHosting>true</EnableComHosting> + <ComHostTypeLibrary>MyTypes.idl<ComHostTypeLibrary /> </PropertyGroup> </Project>Specify the tlb file in the PropertyGroup. This would require us to compile the idl ourselves
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net5.0-windows</TargetFramework> <EnableComHosting>true</EnableComHosting> + <ComHostTypeLibrary>MyTypes.tlb<ComHostTypeLibrary /> </PropertyGroup> </Project>Risks
None that I am aware of.