COM Callable Wrapper for .NET
Basic Steps in Making a DLL in DOT NET which could be called by regular COM objects.
| PatelPlanet | |
| Intermediate | |
| Language: | VB.NET |
| Platform: | Windows |
| VS.NET | |
| 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 reviewsRE: RE: Can't get it to work
Written by Mike Malburg on January 9, 2006Ooops. 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, 2006By 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, 2004Great 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') ...





