Registering a .net framework DLL via
regasm.exe test.dll /codebase
apart other registry keys, regasm.exe
always adds
[HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{dll-guid}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}\]
the
{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}
it is a specific CATID, a component category. When a COM-compatible .NET assembly is registered, adding this CATID that allows applications to list or access all components that belong to that category, simplifying client development and deployment. Indicates that the DLL is part of the integration framework between .NET and COM components.
on
VS2012 on Properties dialog of a
Class library
which is equivalent with
Properties\AssemblyInfo.cs
on project properties check
Register for COM interop and set
x86. Then
save the solution.
and dont forget to
sign the assembly as is requirement
At the moment,
nothing registered on the system registry. Once the
user BUILD the solution those registry entries added (we searched by the GUID) :
to be more specific, Visual Studio register the
.tlb :
Code:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\WOW6432Node\TypeLib\{EB35161C-9A34-4EBE-896D-3975F0816061}]
[HKEY_CLASSES_ROOT\WOW6432Node\TypeLib\{EB35161C-9A34-4EBE-896D-3975F0816061}\1.0]
@="ClassLibrary1"
[HKEY_CLASSES_ROOT\WOW6432Node\TypeLib\{EB35161C-9A34-4EBE-896D-3975F0816061}\1.0\0]
[HKEY_CLASSES_ROOT\WOW6432Node\TypeLib\{EB35161C-9A34-4EBE-896D-3975F0816061}\1.0\0\win32]
@="c:\\comNET\\ClassLibrary1\\ClassLibrary1\\bin\\Debug\\ClassLibrary1.tlb"
[HKEY_CLASSES_ROOT\WOW6432Node\TypeLib\{EB35161C-9A34-4EBE-896D-3975F0816061}\1.0\FLAGS]
@="0"
[HKEY_CLASSES_ROOT\WOW6432Node\TypeLib\{EB35161C-9A34-4EBE-896D-3975F0816061}\1.0\HELPDIR]
@="c:\\comNET\\ClassLibrary1\\ClassLibrary1\\bin\\Debug"
Code:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\Interface\{F56AF0FC-D93B-399E-8FBD-9B72CF50D7D9}]
@="_Class1"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\Interface\{F56AF0FC-D93B-399E-8FBD-9B72CF50D7D9}\ProxyStubClsid32]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\Interface\{F56AF0FC-D93B-399E-8FBD-9B72CF50D7D9}\TypeLib]
@="{EB35161C-9A34-4EBE-896D-3975F0816061}"
"Version"="1.0"
The registry CatID
00020424-0000-0000-C000-000000000046 corresponds to the
IClassFactory interface in Microsoft's COM (Component Object Model) architecture.
Added three classes
- to make accessible the methods you must declare the class AutoDual.
- static methods are not accessible.
- if user prefers, can declare class GUID (otherwise assigned automatically), so do it!
C#:
using System;
using System.Runtime.InteropServices;
namespace ClassLibrary1
{
//[ComVisible(true)]
//[Guid("c28631ad-87bf-49ed-8a2b-d420d461e102")]
//[ComDefaultInterface(typeof(IClass1))] // Interface ID
//[ComDefaultEvent(typeof(IClass1))] // Events ID
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Class1
{
public string GetName(int Id)
{
return "testName";
}
}
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Class2
{
public string GetAddress(int Id)
{
return "testAddress";
}
}
public class Class3
{
public string GetTelephone(int Id)
{
return "testTelephone";
}
}
}
On
developing machine once you have the .net framework
.dll, register the
.dll then generate the .
tlb and register it (.tlb is only for developing) via :
Code:
c:\Windows\Microsoft.NET\Framework\v4.0.30319>regasm.exe c:\a\ClassLibrary1.dll /tlb:c:\a\ClassLibrary1.tlb /codebase /verbose
Reference the .tlb to your VB6 project.
you can
unregister with :
Code:
c:\Windows\Microsoft.NET\Framework\v4.0.30319>regasm.exe c:\a\ClassLibrary1.dll /u /tlb:C:\a\ClassLibrary1.tlb
When we
deploying the application to
clients we have to
register the .dll as
Code:
c:\Windows\Microsoft.NET\Framework\v4.0.30319>regasm.exe c:\a\ClassLibrary1.dll /codebase
deploy ref :
https://stackoverflow.com/a/12384131
https://github.com/PhilJollans/RegToInno
https://github.com/PhilJollans/RegSpy
when " regasm.exe c:\a\ClassLibrary1.dll " the following will be created to registry
Code:
HKEY_CLASSES_ROOT\ClassLibrary1.Class1\
HKEY_CLASSES_ROOT\ClassLibrary1.Class2\
HKEY_CLASSES_ROOT\ClassLibrary1.Class3\
and (here Class3 insert none, because later I made it static)
HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{079C0B3A-038E-37A7-B6A5-3D440862B289}\
HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{079C0B3A-038E-37A7-B6A5-3D440862B289}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}\
HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{9C0B5817-C9D1-3107-B208-C97F1F11EBF7}\
HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{9C0B5817-C9D1-3107-B208-C97F1F11EBF7}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}\
the exact same also for HKEY_LOCAL_MACHINE..
the
required are the
HKEY_CLASSES_ROOT\WOW6432Node entries.
The registry CatID
62C8FE65-4EBB-45e7-B440-6E39B2CDBF29 corresponds to the .NET Category for
COM interop.