Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


calling COM dll from .net application

Posted on 2006-07-18
Medium Priority
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
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
  • 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.

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!


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 375 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Simple Linear Regression

715 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