Midtown Computer Systems Enterprise

Convenient web based access to our favorite computer related Usenet groups.
MCSE.MS is not affiliated with Microsoft corporation, Cisco corporation, Oracle, CompTIA or any other vendor.
Check our Computer Hardware forum | Cell Phones reviews

Go Back  MCSE > Microsoft software reviews > Dot Net tutorials > .NET Framework Setup


.NET Framework Setup microsoft.public.dotnet.framework.setup

 
 
Thread Tools Display Modes
  #1  
Old 11-04-04, 09:13 PM
Namratha Shah \(Nasha\)
Article:TlbImp (21 steps to ans your Interview Q's -.NET FrameWork Tools Series)
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)





  #2  
Old 11-21-04, 07:55 PM
devendert devendert is offline
Junior Member
Join Date: Nov 2004
Re: Article:TlbImp (21 steps to ans your Interview Q's -.NET FrameWork Tools Series)
Excellent Article. I was just looking for this.
I am trying to call a DCOM object in webservice. It is not working.

I hope it works now.

Thanks
Dev
 


Popular forums
A+ (A Plus) Windows 2000 Active directory Exchange 2000 information store
Network+ Windows XP Security Exchange 2000 server administration
MCSE .NET Web services SQL Server
Cisco certification ASP .NET SQL 2000 Programming
Windows 2000 Registry .NET XML Viruses


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:28 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright MCSE braindumps 2003-2006