ActiveX DLL registration in VB.NET

P

Paul Bromley

I am using an ActiveX control in a VB.NET application as there is no
alternate .Net control available to me. The problem is that when I try to
install this appliaction on another machine the DLL is not registered. The
only way aound this that I have found is to build a ismple VB6 application
purely to register the DLL what am I doing wrong? An Interop is being
created. I have been unable to find any information on this one and it ha
been annoying me for months. The VB6 method works fine, I just want a neater
way by VB.NET of achieving this.

Best wishes


Paul Bromley
 
P

Paul Bromley

Those using my application are far from computer literate - tell them to
bring up Run from the Start menu, and they would be lost. I was wondering of
I was missing a way to get a dll automatically registeredduring the
installation process. Otherwise I will have to continue with my VB6
installer first.

Best wishes

Paul Bromley



Anand[MVP} said:
Regsvr32.exe

Rgds,
Anand M
VB.NET MVP
http://www.dotnetindia.com

Paul Bromley said:
I am using an ActiveX control in a VB.NET application as there is no
alternate .Net control available to me. The problem is that when I try to
install this appliaction on another machine the DLL is not registered. The
only way aound this that I have found is to build a ismple VB6 application
purely to register the DLL what am I doing wrong? An Interop is being
created. I have been unable to find any information on this one and it ha
been annoying me for months. The VB6 method works fine, I just want a neater
way by VB.NET of achieving this.

Best wishes


Paul Bromley
 
G

Gagik A.

Paul,
What do you use for installation tool? Most of the installers provide an
option to register a DLL/OCX automatically.

As an alternative solution, you can register the control programmaticaly
when your application starts up. Below is a VB .NET code snippet from .NET
framework SDK documentation that you can use as a starting point for
registering the control and creating the interop programmatically.

Hope this helps
Gagik A
--------------------------------------------------------------------------
Automate your VB, VC++ and .NET component builds
http://www.visualmake.com
--------------------------------------------------------------------------

Imports System
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Runtime.InteropServices

Public Class App
Private Enum RegKind
RegKind_Default = 0
RegKind_Register = 1
RegKind_None = 2
End Enum 'RegKind

<DllImport("oleaut32.dll", CharSet:=CharSet.Unicode,
PreserveSig:=False)> _
Private Shared Sub LoadTypeLibEx(ByVal strTypeLibName As [String], ByVal
regKind As RegKind, <MarshalAs(UnmanagedType.Interface)> ByRef typeLib As
[Object])
End Sub

Public Shared Sub Main()
Dim typeLib As [Object]
LoadTypeLibEx("SHDocVw.dll", RegKind.RegKind_None, typeLib)

If typeLib Is Nothing Then
Console.WriteLine("LoadTypeLibEx failed.")
Return
End If

Dim converter As New TypeLibConverter()
Dim eventHandler As New ConversionEventHandler()
Dim asm As AssemblyBuilder =
converter.ConvertTypeLibToAssembly(typeLib, "ExplorerLib.dll", 0,
eventHandler, Nothing, Nothing, Nothing, Nothing)
asm.Save("ExplorerLib.dll")
End Sub 'Main
End Class 'App
_

Public Class ConversionEventHandler
Implements ITypeLibImporterNotifySink

Public Sub ReportEvent(ByVal eventKind As ImporterEventKind, ByVal
eventCode As Integer, ByVal eventMsg As String) Implements
ITypeLibImporterNotifySink.ReportEvent
' handle warning event here...
End Sub 'ReportEvent

Public Function ResolveRef(ByVal typeLib As Object) As [Assembly]
Implements ITypeLibImporterNotifySink.ResolveRef
' resolve reference here and return a correct assembly...
Return Nothing
End Function 'ResolveRef
End Class 'ConversionEventHandler
---------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top