1

I'm trying to export a TLB file for a F# DLL. For .NET Framework up to 4.8 the following custom build command works:

    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
      <Exec Command="&quot;$(TargetFrameworkSDKToolsDirectory)\tlbexp&quot; /verbose &quot;$(TargetPath)&quot;" />
    </Target>

I've switched to .NET 6.0 (Visual Studio 2022), and the TargetFrameSDKToolsDirectory is pointing to

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\\

What is the equivalent variable to find the .NET Core 6.0 version of tlbexp?

Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116
jsparkes
  • 161
  • 1
  • 11
  • What is wrong with the current path? – Roman Marusyk Jul 21 '21 at 23:41
  • I get the following error: 1>TlbExp : error TX0000: Type library exporter encountered an error while processing 'PCDMindServerSearchStream, PCDGenericSearchStream'. Error: Type library exporter cannot load type 'PCDMindServerSearchStream' (error: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. – jsparkes Jul 22 '21 at 13:52
  • @jsparkes use `/asmpath:'c:/program files/dotnet/shared/your_sdk/version/'` to include libraries to search path, but seems that net48 version is not compatible with netcore libraries, because I get `TlbExp : error TX0000 : Type library exporter encountered an error while processing 'Program, SO'. Error: Type library exporter cannot load type 'Program' (error: Could not load type 'System.Object' from assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.)` – JL0PD Jul 23 '21 at 03:13
  • 1
    According to https://learn.microsoft.com/en-us/dotnet/core/native-interop/expose-components-to-com .NET no longer generates a TLB file. The advice is to write an IDL file describing the interface for use in C++ clients. Maybe I will stick to .NET 4.8 to avoid the extra work for now. – jsparkes Jul 23 '21 at 16:04

1 Answers1

3

You can use the following project as a replacement:
https://github.com/dspace-group/dscom

This works with .net 6.0

Install:
dotnet tool install -g dscom

Run:
dscom tlbexport myassembly.dll

MarkL
  • 76
  • 3