View Single Post
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: create dll using vb.net and how to call it from sql server

 
0
  #2
Nov 28th, 2008
Not sure how detailed or "basic" help you need but let's start with this.

1) Create a VB.NET project and add a class in it.
  1. Public Class Class1
  2.  
  3. Public Sub New()
  4. ' Initialize class
  5.  
  6. End Sub
  7. ' Add properties
  8. ' Add methods
  9.  
  10. End Class
I created a project ClassLibrary1 with Class1. Then compile it, you should now have ClassLibrary1.dll

2) Register assembly: regasm /tlb classlibrary1.dll If you get "... is not a valid .NET assembly" error, you're using wrong version of regasm. Fully qualify it:
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm /tlb classlibrary1.dll"

3) Open regedt32 and search from HKCR your classlibrary1 (press CTRL+F to use Find). You should find it from a place similar to HKCR\TypeLib\{9529A0DE-7DCC-4587-B9B0-3C702F33AF6E}. {9529A0DE-7DCC-4587-B9B0-3C702F33AF6E} is now the ClassID you will use.

4) Check MSDN for the documentation of sp_oacreate. In my case the syntax would be:
sp_OACreate '{9529A0DE-7DCC-4587-B9B0-3C702F33AF6E}' , myToken OUTPUT , 1 and now the integer variable myToken would be the object token to ClassLibrary1.Class1

Hope this helps.

Anyway, a few points if something goes wrong: change from the Class1 "COM Class = True" from the attributes. Now the registration (phase 2) changes to: regsvr32 classlibrary1.dll.
Reply With Quote