calling COM dll from .net application

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.

Who is Participating?
yotamsherConnect With a Mentor Commented:

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?

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?
armansiuAuthor Commented:
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. =*(
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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.

one more option, is it possible, that this api is itself a DotNet assembly?
armansiuAuthor Commented:
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.

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.

armansiuAuthor Commented:
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 =)
armansiuAuthor Commented:
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

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.