[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Create a .TLB file from a .NET DLL?

Posted on 2004-04-30
25
Medium Priority
?
16,029 Views
Last Modified: 2007-12-19
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?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
25 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10966283
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.
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10966354
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10968636
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?
0
 
LVL 4

Expert Comment

by:pml_siva
ID: 10975870
use regsvr32 adodb.dll in the command prompt
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10979356
regsvr32 adodb.dll gave me the following error, I think it was something about could not find DLLRegister entry point or something.

0
 
LVL 48

Accepted Solution

by:
AlexFM earned 2000 total points
ID: 10983619
Read this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconfillingdatasetwithadorecordset.asp

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:

http://support.microsoft.com/default.aspx?scid=kb;en-us;810098

0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10987947
Alex:  

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 adojavas.inc
05/04/2001  01:05p              14,562 adovbs.inc
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?  :)

0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10988170
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.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988325
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
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988332
I was not getting this error before.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988354
Why does the error message refer to CDO.IDataSource

but my actual call is to

CDO.DataSource     (no   "  I   "  before DataSource)

??????
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988414
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?
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988518
Alex:

I tried adding the file

msado15.dll

from this location:

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


======================================

The result was the following showed up in my References:


ADODB
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10988563
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?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 10988586
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.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988645
Alex:

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)
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988648
Is this making any sense to you????????????

I am lost.....
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988686
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988734
Alex:

>>>> 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)
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10988788
Alex:


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

See the last post:

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20976258.html
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 10990993
Do you have MDAC 2.7 or higher? Here you can find a program to verify your MDAC installation:
http://www.microsoft.com/downloads/details.aspx?FamilyID=8f0a8df6-4a21-4b43-bf53-14332ef092c9&displaylang=en
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10991285
ptmcomp:

I am familiar with this utility...and when i ran it it confirmed 2.7   :)
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 11119903
UPDATE:

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 http://www.microsoft.com/MSPress/books/5517.asp

My I aslo reommend:

.NET and COM: The Complete Interoperability Guide  ISBN:067232170X
http://www.amazon.ca/exec/obidos/ASIN/067232170X/componentsnot-20/701-9386310-4703553
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 11120246
More on the MoveFirst problem I described:

http://support.microsoft.com/default.aspx?scid=kb;en-us;273791


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

http://www.codeproject.com/csharp/CsManagedEventSinksHooks.asp

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.  :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

656 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