Solved

calling COM dll from .net application

Posted on 2006-07-18
10
2,792 Views
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.

yours,
armansiu
0
Comment
Question by:armansiu
[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
  • 5
  • 4
10 Comments
 
LVL 7

Expert Comment

by:yotamsher
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?
0
 

Author Comment

by:armansiu
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. =*(
0
 
LVL 7

Expert Comment

by:yotamsher
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.

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!

 
LVL 7

Expert Comment

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

Author Comment

by:armansiu
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.

armansiu
0
 
LVL 7

Expert Comment

by:yotamsher
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.

Yotam
0
 

Author Comment

by:armansiu
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 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
 
LVL 7

Accepted Solution

by:
yotamsher earned 125 total points
ID: 17142367
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
 

Author Comment

by:armansiu
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

armansiu
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to App 4 145
Select specific duplicate row based on specific criteria 4 84
Why use this lambda? 12 96
Error building VS2105 solution from repository 1 61
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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