Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating .TLB file from VB6 project

Status
Not open for further replies.

chiph

Programmer
Jun 9, 1999
9,878
US
Anyone know how to generate a .tlb (COM typelib) file from a VB6 project?

I'm trying to use an existing VB6 COM+ DLL in a .NET project via COM Interop, and I need to give the imported interop assembly a strong name. From what I can tell, I can't do this without using the tlbimp utility, and *it* only takes a .tlb file.

I'm cross-posting this into the VB5/6 forum.

Thanks in advance.
Chip H.
 
I found an answer to my problem in an unlikely place (in with the BizTalk stuff ?!?).

What you need to do to get Interop working with an EnterpriseServices assembly that needs a strong name is:

Create your strong name key file (*.snk) as usual. But instead of using a relative path (..\\..\\chip.snk) you need to put it in the actual bin\debug directory. You then put just the filename in the Wrapper Assembly Key File entry in your project's properties (find project in solution explorer..right-click..properties). You then need to do a successful build so that the strong name is registered in your assembly. You *then* go and add references to your COM+ components and build again. The runtime callable wrapper (like Interop.MSMQ.dll in the obj directory) that gets created will then have a strong name applied.

If you accidentally add your reference to your COM+ component first, you'll need to delete the Interop.* files in the obj directory, as they don't get overwritten automatically.

Chip H.
 
ChipH,

This interop issue came up several times at work a few months ago (@ a company that no longer exist). We went around and around and adopted the very method you mentioned. The only problem was that we had several projects within a solution and once one of the projects was strong named, they all had to be... Though the issue was never corrected and and we learned to love it :( I was able to get interop to work on a side project that I am working on without strong naming becoming an issue.

I used the tlbimp.exe tool to create a .tlb file, registered it with my project, and I haven't had any problems with it. I have included a couple of links to the MSDN site that talk about this. Hope this helps:



dnD
 
Thanks for the reply, dotnetDave. I had looked at those articles, and they didn't really say "you must sign before referencing a COM object", so it didn't register with me.

The TlbImp.exe tool didn't do what I needed (fooled around with it for a couple of hours), as it expected a *.tlb file ... something that VB6 does not produce when it builds (you can get a .pdb for debugging, but not a .tlb for interop or C++ ... go figure). What switches did you use on it to create your .tlb file?

Chip H.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top