Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use my VB dll in .NET?

Status
Not open for further replies.

TheBugSlayer

Programmer
Joined
Sep 22, 2002
Messages
887
Location
US
Hi all.
I have a procedure that uses a API to retrieve a list of SQL Servers on a given domain. I intend to use in on a page I am developing. One of the solution I thought is to wrap the procedure in a dll and use that dll in .NET. Is that possible? If yes please give a example of how to call it.

Do I need to make any modifications to my VB code in order to make it into an assembly in VB .NET for use with ASP?

Thanks for your help.
 
If your .dll is unmanaged VB (e.g a COM object) then you will need to create a COMInterop 'wrapper' to expose the object to the .NET framework. This is easy if you have Visual Studio just right click References in Solution Explorer and then Add Reference. This will open a dialog from which you can browse to your .dll and select it. A new reference will be made to the COM Object in the Bin foolder in the form Interop.object.dll

You can now instantiate the object within your .NET code. If you would have used

Server.CreateObject(table.leg) in ASP you would now use

table oTable = new table.legClass(); in .NET (C#)

If you don't have Visual Studio you will need to use the tlbimp.exe from the command line to create the wrapper. More info on COM Interop can be found on MSDN at


Hope this helps

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Thanks a lot. I will try both rewriting the code in VB .NET (although I don't know how to call an API) and creating a VB6 dll...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top