Create a .TLB file from a .NET DLL?

I am using adodb.dll in a C# class.

why am I not able to do this:

regasm adodb.dll /tlb

I get the following error:

[[command line output]]

C:\EES\BIN\RELEASE>regasm adodb.dll /tlb
Microsoft (R) .NET Framework Assembly Registration Utility 1.0.3705.288
Copyright (C) Microsoft Corporation 1998-2001.  All rights reserved.

Types registered successfully
RegAsm error: CLR assembly c:\ees\bin\release\adodb.dll was imported from a type
 library and can not be re-exported to a type library.  Make sure the type libra
ry from which the assembly was imported is registered.

What does this message mean.......and is there still a way to create a TLB file from the DLL?
Tom KnowltonWeb developerAsked:
Who is Participating?
AlexFMConnect With a Mentor Commented:
Read this:

This article describes how to generate ADODB.DLL using command:
TlbImp "C:\Program Files\Common Files\System\Ado\msado15.dll" /out:ADODB.dll

Try to do this, what result do you have? Do you have msado15.dll on your computer? Try to register it using regsvr32 abd generate adodb.dll after this.

Having ADODB.Dll, try this:;en-us;810098

regasm utility is used to registrate .NET Dll as COM Dll, which makes it available for unmanaged client. Your task is opposite - to use unmanaged COM dll in C# code. To do this, add this Dll to the Project References.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Actually, adodb.dll is managed library, but also in this case you need to add it's reference to your project. adodb.dll is managed wrapper for unmanaged ADO library. You don't need regasm tool in this case, you can use this library directly in C# project.

Consider the case when you are working with unmanaged (for example, VB6) project, and want to use .NET Dll. This is a place to use regasm. But unmanaged project doesn't need to use adodb.dll, it can use directly original ADO Dll, so regasm is not needed also in this case.

In the Project Explorer right-click on References, select Add Reference. In .NET tab select adodb. Now all ADO objects are available using  ADODB prefix, or add line:
using ADODB;
and use them directly.
Tom KnowltonWeb developerAuthor Commented:
For some reason I am getting an error when trying to use the ADODB dll.

"Interface Not Regsitered"

This is a COM problem is it not?

If I am referencing the ADODB.dll in my project References....then why isn't COM picking it up?
use regsvr32 adodb.dll in the command prompt
Tom KnowltonWeb developerAuthor Commented:
regsvr32 adodb.dll gave me the following error, I think it was something about could not find DLLRegister entry point or something.

Tom KnowltonWeb developerAuthor Commented:

I have msado15.dll on my computer at location:

C:\Program Files\Common Files\System\ado

I noticed that inside this folder there are other files.  Not sure about their relevance but here is a list:

07/26/2000  11:00a                 667 adoapt15.reg
07/26/2000  11:00a                 640 adofre15.reg
05/04/2001  01:05p              14,236
05/04/2001  01:05p              14,562
07/26/2000  11:00a                  26 makapt15.bat
07/26/2000  11:00a                  26 makfre15.bat
06/27/2001  02:22p                 543 MDACReadme.htm
07/13/2001  10:30a              24,576 msader15.dll
07/13/2001  10:30a             487,424 msado15.dll
07/13/2001  09:39a              61,440 msado20.tlb
07/13/2001  09:39a              61,440 msado21.tlb
07/13/2001  09:39a              81,920 msado25.tlb
07/13/2001  09:39a              81,920 msado26.tlb
07/13/2001  10:30a             159,744 msadomd.dll
07/13/2001  10:30a              49,152 msador15.dll
07/13/2001  10:30a             180,224 msadox.dll
07/13/2001  10:30a              53,248 msadrh15.dll
07/13/2001  10:31a              90,112 msjro.dll


When I ran

TlbImp "C:\Program Files\Common Files\System\Ado\msado15.dll" /out:ADODB.dll

Here was the result:

TlbImp warning: Primary interop assembly 'ADODB, Version=7.0.3300.0, Culture=neu
tral, PublicKeyToken=b03f5f7f11d50a3a' is already registered for type library 'C
:\Program Files\Common Files\System\ado\msado15.dll'.
Type library imported to C:\Program Files\Common Files\System\ado\adodb.dll

What should I do?  :)

Now try to use this adodb.dll selecting it as reference using Browse button. Try to add it to GAC as described in the second link of my previous post and after this add reference from the list (adodb.dll is in the beginning).
If all this doesn't succeed, try to add COM reference directly to msado15.dll, this should have the same result, but proxy Dll is generated in the project directory.
Tom KnowltonWeb developerAuthor Commented:
Since I added the adodb.dll back into my project source I am now getting this compile error:

N:\ClientDevelopment\NEO\BuyersFund\ExchangeEventSinkClassLibrary\ExchEventSink.cs(137): The best overloaded method match for 'CDO.IDataSource.Open(string, object, ADODB.ConnectModeEnum, ADODB.RecordCreateOptionsEnum, ADODB.RecordOpenOptionsEnum, string, string)' has some invalid arguments
Tom KnowltonWeb developerAuthor Commented:
I was not getting this error before.
Tom KnowltonWeb developerAuthor Commented:
Why does the error message refer to CDO.IDataSource

but my actual call is to

CDO.DataSource     (no   "  I   "  before DataSource)

Tom KnowltonWeb developerAuthor Commented:
C:\Program Files\Microsoft.NET\Primary Interop Assemblies>gacutil /i adodb.dll

Microsoft (R) .NET Global Assembly Cache Utility.  Version 1.0.3705.0
Copyright (C) Microsoft Corporation 1998-2001. All rights reserved.

Assembly successfully added to the cache

C:\Program Files\Microsoft.NET\Primary Interop Assemblies>

So adding to GAC worked?
Tom KnowltonWeb developerAuthor Commented:

I tried adding the file


from this location:

C:\Program Files\Common Files\System\ado


The result was the following showed up in my References:

ExchEventSink.cs - is this your file or proxy generated by Visual Studio?
Maybe adodb.dll supplied with Visual Studio was generated from another version of msado15.dll.
Try to start new project and add adodb.dll reference to it - what happens now?
Adding of msado15.dll directly works, this is good. The difference is that proxy Dll is generated with your project, and adodb.dll is the same proxy supplied by Microsoft. However, this is transparent for your code, so you already have something.
Tom KnowltonWeb developerAuthor Commented:

Okay.......taking a deep breath......inhale....exhale..........

1)  I created a brand new C# Windows Application.

2)  The very next thing I did was go to References....Add References.

3)  Under the .NET tab, about 2 items down was adodb.  Version shown was 7.0.3300.0.  Path was:  C:\Program Files\Microsoft.NET\Primary Interop Assemblies\adodb.dll

4)  Once I selected this file what shows up in my References is lowercase adodb.


So when I add msado15.dll (by browsing to location C:\Program Files\Common Files\System\ado) in References I get

ADODB  (uppercase)

But when I add adodb (by going to Add References, .NET tab, adodb) I get

adodb  (lowercase)
Tom KnowltonWeb developerAuthor Commented:
Is this making any sense to you????????????

I am lost.....
Tom KnowltonWeb developerAuthor Commented:
Tom KnowltonWeb developerAuthor Commented:

>>>> ExchEventSink.cs - is this your file or proxy generated by Visual Studio?

ExchEventSink.cs   contains the source code for my Exchange Server 2000 event sink.

When a new e-mail arrives and is saved to a particular folder....the code inside ExchEventSink.cs is executed.  THIS PART WORKS......BUT......the ADODB code fails and generates this message:

Interface not registered   at ADODB.RecordsetClass.MoveFirst()
   at MyEventSink.ExchEventSink.Process_mail(String bstrURLItem)
Tom KnowltonWeb developerAuthor Commented:

Apparently I now have 3 copies of the file adodb.dll on my hard drive:

See the last post:
Do you have MDAC 2.7 or higher? Here you can find a program to verify your MDAC installation:
Tom KnowltonWeb developerAuthor Commented:

I am familiar with this utility...and when i ran it it confirmed 2.7   :)
Tom KnowltonWeb developerAuthor Commented:

Well, guess what?

I finally had a major breakthrough on this @!#$^% problem that has been driving me crazy for the last few weeks!!!!!!!

It is a very small change.

Apparently the method   MoveFirst(   ) does not work so well with Exchange.

This was the cause of my COMException:   "Interface not registered" error message this entire time.

The solution is to use    Move(1,0)     instead of MoveFirst(  ).

That's it.   Simple.

This answer came courtesy of Tom Rizzo, an author who was kind enough to correspond with me and help me figure-out finally what the problem was.:

Looking for a good book on programming Exchange, Outlook, ADSI and
SharePoint?  Check out

My I aslo reommend:

.NET and COM: The Complete Interoperability Guide  ISBN:067232170X
Tom KnowltonWeb developerAuthor Commented:
More on the MoveFirst problem I described:;en-us;273791

If you are getting into Event Sinks....I recommend the following tutorial:

Make sure and read the article questions and follow-ups at the bottom!

There are a few caveats.  E-mail me at my Profile e-mail address and we can talk about them.  :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.