ActiveX Exe Throwing Type Mismatch 13 Error-VBForums
Results 1 to 20 of 20

Thread: ActiveX Exe Throwing Type Mismatch 13 Error

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    ActiveX Exe Throwing Type Mismatch 13 Error

    Greetings,

    I have an ActiveX exe component that is getting called by a stand alone exe, both were developed in VB 6.0. The component is throwing a "type mismatch" 13 error.

    Here is an excerpt of the code where the ActiveX exe is being declared and instantiated in the program:

    Code:
    	.
    	.
    	.
    	
    	Const errSUMMARY = 9310
    
    	Dim Msg_Summary As CDBSReport  '<-- implements CDBSReport
    	Dim Report_Settings As CDBSReports.rptSummary
    	Dim First_Page As Integer                           
    
        On Error GoTo ErrorHandler
        
        First_Page = Page_Number
        
        'Determine the size of the margins for the current page
        With Word_Document.Sections(Word_Document.Sections.Count).PageSetup
            Top_Margin = IIf(.Orientation = wdOrientPortrait, .TopMargin, .RightMargin)
            Bottom_Margin = IIf(.Orientation = wdOrientPortrait, .BottomMargin, .LeftMargin)
        End With
    
        Set Msg_Summary = New CDBSReports.rptSummary  '<--- error occurs here, rptSummary implements CDBSReport
    	
    	.
    	.
    	.

    When the class gets instantiated, it throws a "type mismatch 13" error. Setting a breakpoint in the component class, I can see it run the initialization method without any errors. Then, it goes right into the terminate method. No errors appear to be thrown in the component. I can't see where the problem is. There are many classes in this ActiveX compoment that implement CDBSReport, and they all throw the same mismatch error when called.

    This code has worked for a long time, and none of the class names or method names have changed. I recently made a change to one of the dlls that this component and the stand alone uses. One of the parameters in a particular method was changed from an integer datatype to a long datatype. I have ensured that the correct datatypes are being passed in. I have spent many hours recompiling everything and still this error occurs. We are running this in a Windows 2008 R2 environment.

    What could be wrong here? How do I debug this?

    Many thanks.
    Last edited by Freedom123; May 16th, 2017 at 05:14 AM. Reason: for clarity

  2. #2
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009
    Location
    ITALY
    Posts
    1,296

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Your code is wrong, because you had first declared Msg_Summary as CDBSReport, while:
    a - Msg_Summary isn't a CDBSReport.rptSummary object.
    b - Msg_Summary IS a CDBSReport object.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Hi Gibra, actually, the class rptSummary implements CDBSReport. So I believe the code is good. I should have been more clear about that.
    Thanks.

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    I thought I would get more coverage that way. Do I need to delete one of them?

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    30,738

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    But the rptSummary isn't in the CDBSReport is it?

    Actually... maybe the question I should be asking is this: are you sure you have that right? Use of the word "Implements" has a very specific meaning. What I hear you saying is that CDBSReport is an Interface that rptSummary then Implements.
    Like so:
    Code:
    Interface ICar
    
    Public Sub StartEngine()
    Public Sub StopEngine()
    Public Function SoundHorn() as Boolean
    
    End Interface
    THAT is an example of an Interface.

    That interface is then implemented:
    Code:
    Public Class MyCar 
    Implements ICar
    
    Public sub StartEngine() Implements ICar.StartEngine
    'Code goes here
    End Sub
    
    Public Sub StopEngine() Implement ICar.StopEngine
    'Code here
    End Sub 
    
    Public Function SoundHorn() as Boolean Implements ICar.SoundHorn
    'And more code here
    End Function
    
    End Class
    So, is that really the case you have here? Something tells me that's not the case.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    30,738

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    No... it just needs to be reported to the admins... which has now been done... Besides us mere mortals can't delete threads. Not even the demi-god moderators can... and the Admins tend to not want to delete things for historical reasons. Odds are they'll be merged into one thread.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    11,835

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Look at your two Dim statements then the set statement where your error occurs the problem seems pretty obvious

  8. #8
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    15,959

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    ... and none of the class names or method names have changed... One of the parameters in a particular method was changed from an integer datatype to a long datatype.
    Changing parameters can break binary compatibility which may have been done? If this is the case, never change the signature of a function when binary compatibility matters. Kinda do what others do: create a new function with Ex or incremental ordinal, i.e., GetOSVersionEx, NewWindow2, etc
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VB and DPI Tutorial} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  9. #9

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Greetings, thank you for the replies. The rptSummary class implements the CDBSReport class. The public properties in the CDBSReport class are implemented in the rptSummary class. In the rptSummary class we have:

    Implements CDBSReport

    This code has not been changed and has worked before.

  10. #10

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    LaVolpe, I have wondered if this might be part of the problem because I did change the signature on a function in a component that is used by CDBSReport. But I did recompile everything... shouldn't that take care of it? Maybe I didn't do in the right order. Are there some guidelines for compiling components, such as what the correct compiling order should be and what the settings should be?
    Thank you

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    15,959

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Not sure exactly how your components were recompiled. If ComponentXYZ was recompiled after changing its parameter from Integer to Long, then ComponentABC that references ComponentXYZ would need to remove the old reference and add the new reference (VB Project References). It might be as simple as that? It does sound like this could be the reason for your mismatch: passing Long to previously registered reference that is still using Integer?

    Edited: Maybe breaking binary compatibility isn't the problem as I'd imagine a different error that "type mistmatch". And when recompiling stuff, if you didn't get any warnings from VB about breaking compatibility, especially after changing a public method's parameter, I'm guessing binary compatibility wasn't in play? Here's a short how-to regarding binary compatibility but doesn't discuss complex, multi-component projects.
    Last edited by LaVolpe; May 16th, 2017 at 09:13 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VB and DPI Tutorial} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #12

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Yes, that sounds like the situation. I didn't change the name of the component after I recompiled it, and I didn't change reference. Do I need to explicitly remove the old reference then add it back in?

  13. #13
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    15,959

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    I modified my previous reply while you were adding your last one.

    I'd try that first, but is it possible you have multiple versions now, same name? Should the previous one have been unregistered before the new was compiled? Hopefully this isn't a start into DLL-hell for you.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VB and DPI Tutorial} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  14. #14

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Thank you LaVolpe. I suspect we may have multiple versions going on. Now I have some things to try. Thank you for the guidance. I'll post the results when we get there.

  15. #15
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    30,419

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    You do get more coverage from multiple threads in different forum, but as a policy, we don't like that so much, as it tends to end in confusion, as answers in one thread may or may not match with answers in different threads. Therefore, we merge, close, or delete duplicate threads. Mods can delete threads and individual posts. At one point, any user could do the same, which resulted in the demise of a very interesting thread when the original poster deleted the original post....which deleted the whole thread. It wasn't a good thread, so I understand their actions, but it sure was interesting.
    My usual boring signature: Nothing

  16. #16

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    OK, thank you for the information. I will keep that in mind for the future.

  17. #17

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Look at your two Dim statements then the set statement where your error occurs the problem seems pretty obvious

  18. #18

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Does it? Maybe you could elaborate.

  19. #19
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    11,835

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Looks like he simply copied and pasted my post from earlier

    Your dim statement shows
    Code:
    Dim Msg_Summary As CDBSReport
    but then your set statement shows something else
    Code:
    Set Msg_Summary = New CDBSReports.rptSummary
    apparently those are two different types hence the type mismatch

    Meanwhile you have
    Code:
    Dim Report_Settings As CDBSReports.rptSummary
    So I would guess that if that set line were to read
    Code:
    Set Report_Settings = New CDBSReports.rptSummary
    or
    Code:
    Set Msg_Summary = New CDBSReport
    Then there would not be a type mismatch thrown

  20. #20

    Thread Starter
    New Member
    Join Date
    May 2017
    Posts
    12

    Re: ActiveX Exe Throwing Type Mismatch 13 Error

    Greetings, thank you for the reply. CDBSReports.rptSummary implements CDBSReport. CDBSReports is an ActiveX out-of-process server and the class rptSummary implements CDBSReport.

    I just discovered the problem. It was because the class id's got messed up in the registry. I totally cleaned out the registry of everything related to this project and then recompiled everything, that did the trick. LaVolpe was definitely on the right track. I appreciate everyone's responses.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.