I am trying to access a VB6.0 DLL with Visual Basic 2005. The VB6 DLL has run for years so I know it works. Below is my VB2005 code. I am getting the following error when I call my RegisterHost function:
"Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"
I am new to Visual Basic 2005 so any help would be greatly appreciated.
Form Load
InitializePlugins()
oPlugin.RegisterHost(Me) - This is where the error happens.
Module Module1
Public oPlugin As Object
Public Sub InitializePlugins()
Try
oPlugin = CreateObject("Agilent34401A.HIOSplugin")
Catch
MessageBox.Show(Err.Description)
End Try
End Sub
End Module
Function in VB 6.0 DLL I am calling:
Public Sub RegisterHost(CallingForm As Object)
On Error GoTo err
Dim MainForm As Object
Set MainForm = CallingForm
Call MainForm.RegisterPlugin(MyName)
err:
End Sub
A .NET 2.0 Windows Form is not a VB6 form; if the DLL is expecting to receive an object of type VB6 form I am afraid you are limited to using VB6 to work with it.
I could be wrong though.
__________________ .NET Resources My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
That won't change the fact that the dll is expecting a VB6 Form object and will get a Windows Forms 2.0 object instead. They are different and incompatible, I'm afraid.
There might be some crazy way to marshal a .NET Form as a VB6 Form but I have a feeling it would involve a lot of hassle and not really be worth it. I recognize the name Agilent, and I'm quite certain they have a .NET equivalent to whatever VB6 library is being used here.
If they don't then my company is in better shape than I thought I went to go check their website but (and I don't know if I am glad or not) their web site seems as useless as mine for obtaining anything important.
__________________ .NET Resources My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Last edited by AtmaWeapon; 08-07-2007 at 12:09 AM.
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET. subscribe