Jump to content
Ron Schuster

How to import Type Library for Managed Code DLLs

Recommended Posts

Our C# .NET team creates Managed Code DLLs for us to call from our Delphi desktop application. They call them "COM-wrapped .NET". We use Regasm.exe (Assembly Registration Tool) to register the Managed Code DLLs. We they are registered I can see them in the Windows registry. Now I have a new one of these and no one can remember how we got these imported into Delphi. We have *_TLB.PAS files for the old ones, so we apparently successfully imported these in Delphi. I expected to go into Component -> Import Component -> Import a Type Library, find it in the list of Registered Type Libraries, and go from there, but none of these show up in the list. They also produced a .TLB file to go with the .DLL, and I can successfully open this file directly (File -> Open) in Delphi and view the classes with all their methods and parameters, but I can't do anything with it from there. What do I need to do to import these .DLLs?

 

Share this post


Link to post

To view COM components from IDE, your assembly should be compiled for 32 BIT explicitly (so you must have two dll register, 1 for 32 bit and one for 64 bit if you produce 64 exe).

 

Other way is to import it using the bin64\tlibimp,exe or /bin/tlibimp.exe utility (produce the _tlb pas file).

 

If you have only the 64 bit dll, you can use it at runtime.

 

Example:

 

"C:\Program Files (x86)\Embarcadero\Studio\23.0\bin64\tlibimp.exe" -Ha+ -Hs+ -Hr+ -Ya- -O+ -R+ -W+ -Wc+ -P+ "C:\Windows\System32\Speech\Common\sapi.dll"

Import SAPI COM from Windows system and generate _TLB PAS file (also call wrapper).

Share this post


Link to post

Angus, As I stated in my original post, it does not appear there. That is the main point of my issue.

Share this post


Link to post
3 hours ago, Ron Schuster said:

Angus, As I stated in my original post, it does not appear there. That is the main point of my issue.

The import menu should also have an "import .NET assembly" item that allows import of a COM-interop-enabled .NET library.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×