开发者

Need to create COM DLL to use in Scripting like "Excel.Application"

I want to create a COM DLL using VSS 2010 and need to register to Registry. My aim is I want u开发者_开发技巧se that created DLL like "Excel.Application", "Word.Application", "Wscript.Shell" kind-of.

I want to create instance using CreateObject / New OleObject methods and use the same in my Scripting (VBScript or JavaScript).

Any one help me to create a COM object and how to register it?

I tried to create COM Object and tried to register using RegSvr32.exe. It says "dll was loaded but no entry point found. Make sure valid dll or ocx"

Here is my code for your ref...

<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1 

Public Const ClassId As String = "b3b13b6c-6de5-47cb-ad6f-0ae5c7ce5c59"
Public Const InterfaceId As String = "68536b50-1b47-42d5-970f-d3d34b56d681"
Public Const EventsId As String = "413fa5c3-76fa-44d0-b753-1f3d3f52dbaf" 

' A creatable COM class must have a Public Sub New() with no parameters, 
' otherwise, the class  will not be
' registered in the COM registry and cannot be created
' via CreateObject.

Public Sub New()
    MyBase.New()
End Sub


Public Sub Test1()
    Console.WriteLine("Test1....")
End Sub

End Class

Thanks,

Shanmugavel.C


  1. Create a CLass Library
  2. Inside the .vb file, Create a Interface first.
  3. Create class by inheriting from Interface.
  4. Create Strong Name under "Signing" TAB of Properties.
  5. Enable the "Register for Com Interop" under "compile" TAB of Properties
  6. Enter the Assembly Information.
  7. Build the Solution.

After this,

  1. Goto "Visual Studio 2010 Command Prompt"
  2. Navigate to dll path
  3. Register the dll using "regasm" like regasm test.dll /tlb:test.tlb

Now Registry Entries will be done under CLSID and Interface. Then

  1. Export to GAC(Global Assembly Cache ie. C:\Windows\Microsoft.Net\Assembly) using "gacutil.exe" like gacutil /i test.dll

That's all.... We can use the COM application....

Refer the links:

http://www.codeproject.com/KB/COM/nettocom.aspx http://www.15seconds.com/issue/040721.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜