Friday, November 27, 2009

how to use an assembly in com server or c++

To make your assembly visible to com object you need to fulfill the following two requirements-

1. You have to generate the tlb file (type library) from your assembly. you can do it by using any one of the following utility provided by .net-

a).One utility is TLBEXP.EXE, the .Net Type Library Exporter. This command line utility takes as input the name of an assembly DLL file to be converted to a Type Library. The programmer can also specify the name of a Type Library file to be created.for Example -

tlbexp assembly.dll /out:tlb_name.tlb

b). 2nd one is
REGASM.EXE. It does two task in a single shot. It generate the tlb and by the time register it as a com client. If you are using TLBEXP.exe than you have to do the 2nd step also.

2. Register your assembly using REGASM.EXE.


Once you have the tlb file and your assembly is registered as a com server you can simply start using it by importing the tlb file.

#import "tlb_name.tlb" raw_interfaces_only


No comments:

Post a Comment