calling COM dll from .net application

Posted on 2006-07-18
Last Modified: 2013-12-14
Hi, experts, I am having a trouble when I am trying to use a COM dll in Visual Studio 2005 .net environment.  I have tried to "Add Reference" after I have added the dll in the Bin.  However, the following error message pops up.

“A reference to bv7api.dll could not be added.  No type libraries were found in the component.”

I have also tried to use regsrv32 to register it, but it still doesn't work.

Then i thinkit might be because the DLL doesn’t have a type library.  Therefore, i did try to use the Windows SDK function, TLBIMP and try to create a type library for the API.  But unfortunately, when i run that, the following error comes out.

C:\>tlbimp aaaapi.dll /out:abc.dll
Microsoft (R) .NET Framework Type Library to Assembly Converter 2.0.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.

TlbImp : error TI0000 : The input file 'C:\aaaapi.dll' is not a valid type library.

or I need to run MIDL.exe to get an IDL file first? i am so lost here....and Visual Studio 2005 doesn't have MIDL.EXE =T

So, I am stuck here.  I can't start on my project until I am able to register the dll.  Since i am working on a client server application, so i cannot just hardcode the path of the dll.  

I am so frustrated now...I have kept trying to register that for 2 days already =T  I think I really do need a hand from an expert~~ Thanks.

Question by:armansiu
  • 5
  • 4

Expert Comment

ID: 17133920
Are you sure it is a com DLL?
sounds strange. if regsrv32 fails, then the chances are this is not a com server
did you use it through any other program?

Author Comment

ID: 17137861
The DLL is a API, so I assume it's a com dll.
I've succeeded by making a Windows Application and then put the dll in the same folder as the exe file.
So I don't need to register or add it as reference. But this is not the way I want since I am making an client and server application.  So I need to keep the dll in the server side. =*(

Expert Comment

ID: 17139773
armansiu hi

from your description I'm certain that this is not a com dll.
a com dll which is not registered, would not load even when located in the same directory.
a lot of APIs are released as "simple C" dlls, so this is realy not a sign.

still such API can be called from DotNet app.

can you describe a little more what are you trying to do.
plus what is this API
and what functions does it have (the types of parameters and output are important.

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.


Expert Comment

ID: 17139828
one more option, is it possible, that this api is itself a DotNet assembly?

Author Comment

ID: 17140423
hi, Yotamsher,
This API I have has whole bunch of functions inside which I need to call them with some inputs.
That is not wrapped up in a class I believe.  There are just lots of defined functions in there.
the input parameters are some defined structure, and the output is just normal integer
here is the normal flow of what I need to do

1) assign values to the structure record
2) call the function
   dim result as integer = SomeFunction(Record)
3) check the returned value from result

You mentioned that the dll won't load even it is located in the same directory, so how can I do that in server client application?
I have tried to use
Declare Function LogonWithDir Lib "API.dll" (ByRef record As LogonRecord) As Integer

but the API.dll must be in the same folder as the compiled stuff.  So I am just wondering whether I can put that in the Bin folder and the program will link to it automatically?

Anyway, thx so much.


Expert Comment

ID: 17141498
armansiu hi

can you describe the architecture of what you planned.
I don't get where did you plan to put this dll (Server?)
and how did you plan to use it (Remote .net?)

I have the filling, your problem, is not that tough, I just miss a lot of details.


Author Comment

ID: 17141788
ok, Yotam
it's just simply a multi-tier architecture application.  I have gotten this API which will establish a connection with the database.  So after the users logon to application (might use, they are going to run the functions in that API to work with the database.  Since there are more than one users, so the dll should be in the server only.  Otherwise, every clients' machines will need a copy of the dll in order to run the application.  So the Dll will be in ther server only and the clients are gonna using it remotely~  hope this is clear enough.  Once again, thank you very much, Yotam =)

Accepted Solution

yotamsher earned 125 total points
ID: 17142367

so your asp. net can call this dll in two ways:
1) Directly, you'll just have to put it in the path, or better in a directory, which IIS can load dlls from
2) by Wrapping it with a DotNet assembly which will use the interop services
3) by Wrapping it with Com.

by gut feeling I prefer option 2.

one more question: what OS is the ASP gonna be installed on?


Author Comment

ID: 17145861
what command do I need for using interop services?
umm...i have read an article about doing something by creating another activeX dll to call the API dll, is that the method u talking about?

i am gonna installed it on windows server 2003


Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tviruailstringtree sort multi columns on header click 1 63
Please explain: Aspect Oriented Programming 2 93
Re-position the objects 7 109
simplest php form 3 79
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 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