-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Nasha
Message 1 in Discussion

 
Type Library Importer : tlbImp 
This tool is used to convert the type library definitons found in COM components to 
.NET assembly. This tool works on the entire type 
library at the same time and hence you cannot use this tool to generate type 
information for a particular type found in the COM 
Component. The assemblies that are produced by this tool can be easily strong named by 
using the /keyfile or /keycontainer options. 
Lets checkout the tlbimp tool options :- 
1) Go to the VS.Net command prompt. 
2) type tlbimp /? and all the option will be displayed. I have listed a few imp ones 
here. 
/out:FileName File name of assembly to be produced 
/namespace:Namespace Namespace of the assembly to be produced 
/publickey:FileName File containing strong name public key 
/keyfile:FileName File containing strong name key pair 
/keycontainer:FileName Key container holding strong name key pair 
/delaysign Force strong name delay signing 
/nologo Prevents TlbImp from displaying logo 
/primary Produce a primary interop assembly 
/asmversion:Version Version number of the assembly to be produced :- The assembly 
version must be specified as:Major.Minor.Build.Revision. 
/reference:FileName File name of assembly to use to resolve references :- Multiple 
reference assemblies can be specified by using the /reference option multiple times. 
Lets now import a COM type library and check out some of these features.  
3) Create a new Windows Application. 
4) To view the list of COM components on your machine right click on the project and 
select add reference. In the Add refernce dialog select the COM tab.This tab will 
display all the COM components on your machine. 
5) I have selected to import the microsoft rich text control i.e. RICHTX32.ocx.This 
control will be placed in C:/winnt/system32. 
6) Copy the control to your project folder and excute the below command to generate 
the assembly. 
tlbimp richtx32.ocx 
7) You should get a message saying : "Type library imported to RichTextLib.dll". 
This dll that we have created can be strong named by using /keyfile: or /keycontainer 
or /public key option. 
8) Generate a strong name key to strong name the assembly with  
sn -k MyKey.snk. 
9) Regenerate your assembly with a strong name as follows : 
tlbimp richtx32.ocx /keyfile:MyKey.snk 
10) To change the name of the assembly produced by the tlbimp use the /out: option 
tlbimp richtx32.ocx /out:Namratha.dll 
11)Let us now copt another file called "MSACC9.OLB". You find this file on any machine 
with MSOffice in the "<drive>:\Program Files\Microsoft Office\Office" folder. 
12) Now crearte an interop assembly for this Component with the below command 
tlbimp msacc9.olb  
13) You will notice that it creates the following 5 assemblies 
ADODB.dll 
DAO.dll 
Office.dll 
VBIDE.dll 
Along with the main one "Access.dll" 
13) Here this assembly is internally referencing the first four assemblies and hence 
it has created assemblies for the same also. 
14) Microsoft does provide us with the primary interop for ADODB.dll ... hence if you 
want refer to the primary interop assembly and avoid generation of a new interop 
assembly use the /reference option. 
15) You will find all the primary interop assemblies in "<drive>:\Program 
Files\Microsoft.NET\Primary Interop Assemblies" folder where drive is where .NET is 
installed. You will see a primary interop for ADODB also. 
16) You can use the following command to refer to the existing Primary Interop 
Assembly (PIA .... is not Pakistan International Airlines ..just kidding ) adodb.dll. 
tlbimp msacc9.olb /reference:"C:\Program Files\Microsoft.NET\PrimaryInterop 
Assemblies\adodb.dll" /verbose 
17) The /verbose option will show you all the details while creating the interop 
assembly. 
18) If want your assembly to only refer a set of assemblies that is you have all its 
referneced assemblies you can give multiple references while creating the Interop 
Assembly and for tlbimp to use only those assemblies you can specify the /strictref 
option. By doing this tldimp will only and only refer to those assembly files which 
you have metioned with /reference option. 
19) Well If you want to create a PIA for your own COM component then use the /primary 
option while creating the assembly. 
20) Use the /asmversion option to maintain version of your PIA's. 
21) Now we are ready to use these assemblies in our project and inanswering our 
interview questions :). 
  
-- Please post your queries and comments for my articles in the usergroup for the 
benefit of all. I hope this step from my end is helpful to all of us.  
Regards, 
Namratha (Nasha) 
 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to