Visual Studio .NET in general generates both .dll and .tlb files when the solution is built for creating an assembly. But if we are using Express edition, the .tlb file is not generated automatically, we need to explicitly create it.
This tip shows how to achieve the above objective by following the steps given below:
Create the assembly first.
Make sure that “Register for COM Interop” check box is selected. And sign the dll for a “Strong name key file”.
To make our dll compatible with COM components we need to have the following section in “AssemblyInfo.cs” set to true i.e [assembly:ComVisible(true)]
Build the solution. And then we have our dll generated.
But we are still left with the .tlb file.
So for this we need to register the dll in GAC (Global Assembly Cache) by the following command. But prior to that we need to “drag and drop” (No copy/Paste works) the dll file from the source folder (refers to respective application folder where the dll resides) to “C:\WINDOWS\assembly”.Then we can call the command from command prompt as shown below :
“Regasm AssemblyName.dll/tlb “
1. AssemblyName.dll:-The full path where dll resides needs to be given.
2. Open a command prompt at the path where Regasm is located. For example, the .NET Framework 2.0 default installation path is C:\Windows\Microsoft.NET\Framework\v2.0.50727.