Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Problems accessing a VB6 DLL with VB2005


Reply
 
Thread Tools Display Modes
  #1  
Old 08-06-2007, 12:53 PM
Scottman1925 Scottman1925 is offline
Newcomer
 
Join Date: Jul 2007
Posts: 6
Default Problems accessing a VB6 DLL with VB2005


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
Reply With Quote
  #2  
Old 08-06-2007, 12:59 PM
AtmaWeapon's Avatar
AtmaWeapon AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,416
Default

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.
Reply With Quote
  #3  
Old 08-06-2007, 04:54 PM
Eduardo Lorenzo's Avatar
Eduardo Lorenzo Eduardo Lorenzo is offline
Senior Contributor
 
Join Date: Jun 2006
Location: Manila, Philippines
Posts: 846
Default

you might want to register the VB6 dll using RegAsm or RegSvr32 and change your .Net reference to the registered version.
__________________
Pinoy ako.. ipinagmamalaki ko.
Reply With Quote
  #4  
Old 08-07-2007, 12:03 AM
AtmaWeapon's Avatar
AtmaWeapon AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,416
Default

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.
Reply With Quote
  #5  
Old 08-07-2007, 12:15 AM
Eduardo Lorenzo's Avatar
Eduardo Lorenzo Eduardo Lorenzo is offline
Senior Contributor
 
Join Date: Jun 2006
Location: Manila, Philippines
Posts: 846
Default

my bad. I didn't read the entire post.
Please accept my apologies Scottman1925. I did not intend to traumatize your first visit.

Welcome to the forums!
__________________
Pinoy ako.. ipinagmamalaki ko.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
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
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->