Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Library Generation for .NET Core COM interop #13374

Closed
bclothier opened this issue Sep 7, 2019 · 8 comments
Closed

Type Library Generation for .NET Core COM interop #13374

bclothier opened this issue Sep 7, 2019 · 8 comments
Labels
area-Interop-coreclr question Answer questions and provide assistance, not an issue with source code or documentation.
Milestone

Comments

@bclothier
Copy link

At the present, .NET Core does not support type library generation. However, we still can generate an arbitrary type library from an IDL file and compiling with MIDL. Would there be issues with using such .tlb file generated this way to describe a .NET Core DLL containing the COM types, assuming of course the description is correct?

@jeffschwMSFT
Copy link
Member

@bclothier the current path for the scenario you describe is to use the .NET Framework 4.8 tlbimp to create the PIA. Or if you are using Visual Studio, you can use Embedded Interop Types with this registered tlb. Please let us know if you have any issue with this.

@bclothier
Copy link
Author

@jeffschwMSFT you seem to be talking about importing COM types. I'm talking about exporting COM types. In a .NET FX assembly, that would have been done with either the regasm.exe or tlbexp.exe, assuming that the types within the assembly also have appropriate attributes decorated on the types.

My question deals with the fact that .NET Core no longer uses mscoree.dll to perform the marshaling of .NET types into COM. AIUI, the marshalling in .NET FX is possible because when we register the COM types, registry entries are made describing the category and additional entries to help the marshaler locate the assembly & type. If I'm not mistaken, none of that applies with the new COM marshaling model that .NET Core uses. What I'm asking is whether the new model is 100% compatible with specifications that a type library would expect from an implementation DLL because as I noted, we can build a type library without any implementation using the midl compiler. Whether it will work with the .NET Core DLL out of the box is what I want to know.

@jeffschwMSFT
Copy link
Member

.NET Core also supports .NET COM servers (so the export scenario). If you build a .NET Core COM server, you can register via regsvr32 (similar to native COM). The tlbexp scenario should be possible. What is the scenario you are looking for when using the tlb?

cc @AaronRobinsonMSFT @jkoritzinsky

@bclothier
Copy link
Author

I'm primarily interested in knowing whether it's safe to write a IDL file and compile the type library from the midl.exe compiler to describe the COM types within the .NET Core DLL or whether there would be limitations because I did not see that documented. The fact that one can use regsvr32 implies that it should be compatible with a type library built in this manner without using any .NET specific tools such as tlbexp.exe.

@jeffschwMSFT
Copy link
Member

It is our expectation that this scenario should work, but there are complications and rough edges. The .NET Framework tlbexp loads the assembly and will produce the tlb. For the actual COM interface, this should be just fine. But you can imagine there are features/types introduced in .NET Core that .NET Framework may not be able to load.
We understand that a full .NET Core tlbexp story is not yet in place, so please do give it a try and provide us feedback. With that we can better prioritize the scenario.

@jkoritzinsky
Copy link
Member

@bclothier as @jeffschwMSFT says, tlbexp will have some rough edges. However, manually writing an IDL file to describe COM types in your .NET Core DLL should work as long as it is accurate.

@bclothier
Copy link
Author

Thanks! That's a great news.

Just as a FYI - we currently use a IDL file for our project to work around some limitations in the .NET FX's attributes, mainly the inability to mark types as restricted and to provide a more friendly names for the enumeration members as tlbexp/regasm's default is to name them EnumName_MemberName which is usually a mouthful and not really standard in classic VB's parlence.

@jkotas jkotas closed this as completed Sep 27, 2019
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 3.1 milestone Jan 31, 2020
@kgreed
Copy link

kgreed commented Mar 8, 2020

I am keen to learn how to create a TLB file. Is there any step by step guide? I asked also here

@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Interop-coreclr question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

6 participants