Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2932
  • Last Modified:

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.

yours,
armansiu
0
armansiu
Asked:
armansiu
  • 5
  • 4
1 Solution
 
yotamsherCommented:
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?
0
 
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. =*(
0
 
yotamsherCommented:
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.

Yotam
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Yotam
0
 
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 asp.net), 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 =)
0
 
yotamsherCommented:
ok

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?

Yotam
0
 
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

armansiu
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now