473,761 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Article : Tlbexp .exe and Regasm.exe (.Net FrameWork Tools Series)

Hey Guys,

TlbExp.exe and Regasm.exe tools aid us in exporting assembly information to
a type library so that non .Net Applications or unmanaged code use this type
library information to call .Net assembly.

Just like tlbimp which works on the entire COM Component (check out
yesterdays article) tlbexp also works on the entire assembly.

The entire assembly is converted at the same time. You cannot use it to
generate type information for a subset of the types.

Tbexp only generates the type library information for an assembly but it
does not register the type libraries unlike regasm.exe

Let us now create an assembly for which we will create a type library and
use it through Visual Basic.

1) Open a new dotnet project (Class Library).
2) Add a class to the project called MyClass as below.

public class MyClass
{
public MyClass()
{
}
public int Add (int i , int j)
{
return i +j;
}
public int Mul (int i , int j)
{
return i *j;
}
}

3) Strong name your assembly, Compile the project and create the assembly.
4) Go to the visual studio command prompt and type tlbexp /? to explore all
the options. I have enlisted them here
/out:FileName File name of type library to be produced
/nologo Prevents TlbExp from displaying logo
/silent Prevents TlbExp from displaying success
message
/verbose Displays extra information
/names:FileName A file in which each line specifies the captialization
of a name in the type library.
/? or /help Display this usage message

5) To create a typelibrary from it type the following command tlbexp
<application name>.dll e.g. tlbexp tlbexp.dll
6) If it the export was successful a success message diplaying you the
entire path and the name of the .tlb will be shown to you.

Assembly exported to F:\Net\tlbexp\b in\Debug\tlbexp .tlb

7) You can also use the /verbose option to check out the details of the
classes that were exported.
8) Although our typelibrary is created our assembly is not yet registered.
You can register the assembly using regasm tool.
9) Go to visual studio command prompt and type regasm /? to explore all the
options. I have enlisted them here

/unregister Unregister types
/tlb[:FileName] Export the assembly to the specified type library
and register it
/regfile[:FileName] Generate a reg file with the specified name instead
of registering the types. This option cannot be used with
the /u or /tlb options
/codebase Set the code base in the registry
/registered Only refer to already registered type libraries
/nologo Prevents RegAsm from displaying logo
/silent Silent mode. Prevents displaying of success
messages
/verbose Displays extra information
/? or /help Display this usage message

10) To only register the assembly use the following command
regasm <application name>.dll e.g. regasm TlbExp.dll
11) You can also create a ,reg file containing all the registry entries
regasm TlbExp.dll /regfile:myTlbEx p.dll .reg
12) You also create typelibrary from assembly using regasm tool by using
/tlb option.

13) To use this component from VB 6.0 put the assembly in GAC. You can do
this by either using gacutil or just drag and drop the assembly in
<drive>/winnt/assembly folder.

14) You can now use this assembly from VB 6.0 .
15) Open a VB std project. Go to references . Select the .tlb file that we
generated from the list.
16) Yes you can now use your .Net assembly from VB 6.0 :).

Sample code of using your .NET assembly from VB

Dim tlbExp As tlbExp.MyClass
Set tlbExp = New tlbExp.MyClass
Label1.Caption = tlbExp.Add(1, 2)

Note : You cannot use tlbexp on an assembly produced by tlbimp coz in that
case u can directly use type library which was used to produce the
assembly.

-- 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)

Nov 17 '05 #1
0 1744

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2365
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Before we start with our sample app we need to view the security configuration files on the machine. You will find them under <drive>\WInNT\Microsoft.NET\FrameWork\<version>\Config Enterprise Level Security configuration file is :- enterprise.config Machine Level Security configuration file is :- security.config
0
5544
by: Namratha Shah \(Nasha\) | last post by:
Hi All, Assembly linker is a tool which is used to create an assembly by combining one or more .netmodules and resource files. In simple words an .netmodule is an IL file that does not have manifest in it .... you can say its an assembly without the manifest ... and hence a non -assembly file containing IL code. In the yesterday's example we saw how we can create the .resources file
1
4026
by: Namratha Shah \(Nasha\) | last post by:
Hi All, This is a resource file generation tool which converts an xml based resource formats to .net resource file i.e. (.resources) and vice-versa. Today we will see how we will generate ==> .txt files from .resources or .resx files. ==> .resources files from text or .resx files.
0
1381
by: Namratha Shah \(Nasha\) | last post by:
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.
0
2095
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to allow it ro run then it will execute, the code execution depends on the permission provided to the assembly. If the code is not trusted wnough to run or it attempts to perform an action which doe not have the required permissions then its execution...
0
1880
by: Namratha Shah \(Nasha\) | last post by:
Hey Group, After a long week end I am back again. Its nice and refreshing after a short vacation so lets get started with .NET once again. Today we will discuss about Isolated Storage. This is one of the topics which I find interesting as I feel that it has a lot of practical usage or applicability. We all know that all applications need some storage space to archive certain
0
1164
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, TlbExp.exe and Regasm.exe tools aid us in exporting assembly information to a type library so that non .Net Applications or unmanaged code use this type library information to call .Net assembly. Just like tlbimp which works on the entire COM Component (check out yesterdays article) tlbexp also works on the entire assembly. The entire assembly is converted at the same time. You cannot use it to
0
1056
by: R. Rajesh Jeba Anbiah | last post by:
Anyone knows of any good testing framework or tools for PHP? I need a system that creates some random records depending upon the DB schema or so and then checks the output of the script. Testing scripts might work, but I want to play with the DB too--not only the form inputs and etc. -- <?php echo 'Just another PHP saint'; ?> Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
1
1203
by: lilaz | last post by:
interesting python module with file find, grep and in-place search/substitute capabilities: scriptutil module intro
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.