[Webinar] Streamline your web hosting managementRegister Today


Importing .tbl files

Posted on 2006-05-29
Medium Priority
Last Modified: 2012-06-27

I am having trouble importing .tbl files using Delphi 7 and 2005.  

I am creating assemblies using Visual Studio .NET which provides a tool to access them as if they where COM objects.  This tool creates a .tbl file for the assembly.

When I try to import this file using the "Import Type Library" tool of Delphi I always get this message :

"An error occured while referencing a user defined type.  This may be caused by a missing or unregistered type library."

At first I thought that there was a problem with the file itself so I tried to use it with another programming language.  I loaded MS-Access, created a form and used the "Reference" menu to add a reference to the .tbl file.  Once done, could create objects from my class in my assembly and could easily use the HelloWorld method I implemented for testing purpose.  In other words, the tbl seems to work fine.

I tried to import the tbl file with both Delphi 7 and Delphi 2005 without success.

Can anyone help me ?


Question by:qas
  • 3
  • 3
LVL 28

Expert Comment

ID: 16784644
did you regsvr32 that COM dll?

Author Comment

ID: 16785510
Hi :)

Nope I did not because the dll IS NOT a COM dll, it's a .NET assembly which cannot be registered in the Windows registry but in the Global Assembly Cache.

Microsoft knows that lots of softwares won't be able to use assemblies for a while so they created a tool to interface assemblies as COM objects through a .tbl file.  This tool (embedded into Visual Studio, it's just a checkbox labeled something like "Register COM Interop") creates the .tbl file along with the .dll.

And the .tbl actually works!  I could use it with MS-Access with no problem and I am pretty sure that if I had an old VB6 on hand I could use it the same way.

Any hint ?

Thanks :)
LVL 28

Expert Comment

ID: 16786102
could you post that hello world thingie source code so that I can test? I have vs2003 and .net 1.1 and d7/ just never wrote com in vs :)
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 16786205
Hi !

Here is what I do (I am translating from a french version of VS so maybe the wording isn't accurate)

--------- Creating the assembly ---------
- New project --> Class library
- Write this code in Class1.vb:

  Public Class MyTestClass
      Public Sub TestMsg()
      End Sub
  End Class

- Project Properties --> Configuration properties --> Generate (3rd option) --> Check the "Register COM Interop" Checkbox
- Build the project

--------- Testing in Access ---------
- Start Access
- Create new database
- Create new form
- Drop a button on form
- Select an event and select the code generator
- Select Tools --> References...
- Click "Browse"
- Select the .tlb file which is located in the BIN directory of the VS project created earlier
- Make sure the library is checked in the list
- Click OK to get back to code
- Insert this code:

  Dim X as New MyTestClass

- Run the form, get the TEST message

--------- Testing in Delphi ---------
- Start Delphi, new application
- Select Project --> Import type Library
- Click Add and browse for the .tbl
- Click Create Unit:  error!


LVL 28

Accepted Solution

2266180 earned 500 total points
ID: 16788122
hm... I don't have vb installed, only C# and have done what you said and used this code:

using System;

namespace ClassLibrary1
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      public class Class1
            public Class1()
                  // TODO: Add constructor logic here
            public int TestMsg()
                  int i;
                  String s = "";
                  for (i=0;i<10;i++)
                        s = s + i.ToString();
                  if (s.Equals("s"))
                        return 0;// this never happens but who cares anyway :)
                        throw new Exception(s);// didn't find a fast way to display a message so this will have to do

then imported the tlb and there was no error. however the TestMsg function was not generated. at first I thought there was some optimization and that is why I wrote that weird code.
PS - I noticed I don't have ms access here. so couldn't test the other way
LVL 27

Expert Comment

ID: 16788680
If you have a .NET dll file then :-

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\regasm DotNet.dll /tlb:DotNet.tlb

produces a .tbl file which one can import or process to IDL etc....

Author Comment

ID: 16792540
well I feel stupid...

Whether my Delphi or .NET installation must be corrupted because I tried on another machine and it worked fine on my first attempt.

By the way, to get the TestMsg function working in Delphi you have to create an Interface and the implement it in the class first (in Visual Studio).  It is the interface that will hold the function's declaration.

Thanks :)

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question