COM Callable Wrapper for .NET

40586 Users read it.
by patelplanet com (October 29, 2002)

Basic Steps in Making a DLL in DOT NET which could be called by regular COM objects.

User Rating (68 votes)
4 reviews available | Read the reviews »
Author(s):PatelPlanet
User Level:Intermediate
Language:VB.NET
Platform:Windows
Product(s):VS.NET
Code Download:External link

Basic Steps in Making a DLL in DOT NET which could be called by regular COM objects:

NB:*Although we have an example in the microsoft.com site..that Example never works

*For Safety make all the parameters string type

1. Struct of Lib:

Imports System
Namespace CCWComponent
    Public Class CCWClass
        Public Function PassStr(ByVal a As String) As String
            PassStr = "Hi From .NET Component " & a
        End Function
    End Class
End Namespace

2. Uning the Dot net command prompt Create a Strong Name

c:/>SN -k StrongName.snk

3. OPEN AssemblyInfo.VB of the CLASS library and make changes here

 <Assembly: AssemblyTitle("Sunrise 10G Binary Updater")>
 <Assembly: AssemblyDescription("Sunrise 10G Binary Updater By Shrimant Patel")>

4. Add Another Line to AssemblyInfo.VB giving path to the strong name created in Step 2:

<Assembly: AssemblyKeyFile("C:\StrongName.snk")>

5. Compile the Class Lib in Release mode:

6. Run the following commands from the Dot net Command Prompt.

NB:Change the Directory to the default output dir of the Class Lib where the compiled DLL could be found.

tlbexp DLL_FOR_10G.dll /out:DLL_FOR_10G.tlb
regasm /tlb=DLL_FOR_10G.tlb DLL_FOR_10G.dll
gacutil /if DLL_FOR_10G.dll

Usage FROM ASP

SET OBJMSGBOX = Server.CreateObject("CCWComponent.CCWClass")
Response.write OBJMSGBOX.PassStr("AND ASP")

Usage FROM VB6

Dim OBJMSGBOX as New CCWComponent.CCWClass
Msgbox OBJMSGBOX.PassStr("AND ASP")

User Reviews

Total of 4 reviews
RE: RE: Can't get it to work
Written by Mike Malburg on January 9, 2006

Ooops. Meant to say 'Root Namespace' not 'Assembly Name' in the above post. You can just delete the Root Namespace if you want in the options.

RE: Can't get it to work
Written by Mike Malburg on January 9, 2006

By default in Visual Studio .Net 2003, there is a default Assembly Name that is created when you create a project. So if you named your project 'CCWComponent' when creating the project and have not messed with the Assembly Name for the project ...

RE: Can't get it to work
Written by David Darling on August 24, 2005

+I had the same problem. +I created a VB.Net project in d:\projects\VBNet\Security. +It was called Security.vbproj. +I created a Password.vb class something like this. Namespace Security Public Class Password Public Function ...

Can't get it to work
Written by Dermot Carey on September 29, 2004

Great clean article but when i try to call the method in asp i get: <%@ language='VBScript' %><HTML><BODY> SET OBJMSGBOX = Server.CreateObject('CCWComponent.CCWClass') Response.write OBJMSGBOX.PassStr('AND ASP') ...

Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency