ActiveX EXE with 3 SingleUse Classes causes error

I have an ActiveX EXE project that has 3 classes that I want to use in my main project.  All 3 classes are set to:

DataBindingBehavior=0 - vbNon
Instancing=3 - SingleUse
Persistable=0 - NotPersistable

When I try to compile like this I get the following error:

"Variable uses an Automation type not supported in Visual Basic."

But, if I set 2 of my classes Instancing properties to 1 - Private, it compiles just fine.  Am I doing something wrong?  Shouldn't I be able to have 3 exposed classes in my ActiveX EXE?  I have tried setting each of the 3 classes to 3 - SingleUse, and as long as only 1 is set to SingleUse and the other 2 are Private, it compiles just fine, so it doesn't seem to matter which class has which property, just that only 1 has something besides Private.  Any ideas experts?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
Create 1 Main class that exposes all other classes.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
codeconquerorAuthor Commented:
I can't do that.  I need to be able to do things like the following:

Dim dbConn As SISSvrCommLib.cDBConnection
Dim rsRecs As SISSvrCommLib.cDBRecordset
Set dbConn = New SISSvrCommLib.cDBConnection
dbConn.ConnectionString = "Driver={SQL Server};Server=MyServer;Database=MyDatabase"
Set rsRecs = New SISSvrCommLib.cDBRecordset
With rsRecs
     .CursorLocation = adUseClient
     .Open "Select * From MyTable", dbConn, adOpenStatic, adLockPessimistic
     If Not .EOF Then .MoveLast
     If Not .BOF Then .MoveFirst
End With

I need to integrate these objects into existing projects, so minimal code changes are a must.  If I put the classes directly in the main EXE, it works just fine, but I need them to execute code asynchronously in the separate activex EXE.  Any ideas?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
You will need to add 2 lines on the application startup code:
Dim gActiveXExeMain as SSISvrCommLib.MainClass
set gActiveXExeMain = NEW SSISvrCommLib.MainClass

For the rest, you will only need to change "1" line:

Set dbConn = New SISSvrCommLib.cDBConnection
will change to
Set dbConn = gActiveXExeMain.NewcDBConnection

Where your main class implement this NewcDBConnection function as being

Public Function NewcDBConnection() as SSISvrCommLib.cDBConnection
  set NewcDBConnection= NEW SSISvrCommLib.cDBConnection
End Function


Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
Of course, the other option would be to create 1 activeX exe project per class ;-)
codeconquerorAuthor Commented:
Yeah, I just found an older project where I had the same issue and now I realize what I did.

I have to create the 1 exposed class, and the others as PublicNotCreatable.  In my main program, when I want to use someting like:

Set dbConn = New SISSvrCommLib.cDBConnection

I need to use

Set dbConn = scoSvrCommObj.GetcDBConnection

And make the GetcDBConnection return the New cDBConnection object from my ActiveX EXE.

Thanks angelIII.
You might need to upgrade. This is a known bug.

Microsoft Data Access Components (MDAC) 2.8
Guy Hengel [angelIII / a3]Billing EngineerCommented:
egl1044, I assume you posted to the wrong topic :-)
codeconquerorAuthor Commented:
I have MDAC 2.8.  I installed that even before upgrading to XP SP2 which also includes 2.8.  I don't think it has anything to do with MDAC, its the Instancing property on the class itself that causes a problem.

But, just for Ss and Gs, I'm going to have my reference point to 2.5 instead of 2.8 and see if I get any different results, because I'm still getting the error even though I'm following the same procedure as I did for the last project I had to do like this.  I'll post back after some test with the MDAC because I've seem some weird results when I tried to have my main EXE reference 2.8 instead of 2.6.
I understand..Maybe MDAC 2.7 SP1 is an option.
codeconquerorAuthor Commented:
Well, ruled out any MDAC issues.  I had a few ADO_LONGPTR parameters being passed to some of the properties, but I changed my reference to MDAC 2.5 and changed the ADO_LONGPTRs to Longs, but still got the same issue.  :(
codeconquerorAuthor Commented:
I tried with 2.8, 2.7, 2.6, and now 2.5.  Same issue.  Now, I have 2 classes marked as PublicNotCreateable and only 1 as SingleUse, but I get the same error.  It only goes away if I set 2 of them to Private and 1 to SingleUse.  Any ideas guys?
codeconquerorAuthor Commented:
If someone else gives an answer to this, I'll gladly post another question for 500 pts for them.  :)
codeconq, is 2.7 upgraded w/ SP1?
codeconquerorAuthor Commented:
I'm pretty sure it was.  I install updates almost immediately as they become available.  Is there a way I can check it?
I think it is SP1 that comes with XP SP1, but there might be another release for bug fixes
codeconquerorAuthor Commented:
Downloaded component checker, it has SP1 as does 2.8.
codeconquerorAuthor Commented:
Please post any responses to the following Question so that points can be awarded for the help:

Please DO NOT post anymore comments in this thread because I will be unable to reward your efforts.  Thanks guys.  :)
codeconquerorAuthor Commented:
It definitely has something to do with my code.  I just rem'd out all my code in the classes, compiles just fine.  I'm not using anything weird in my classes, but it does reinforce the theory from egl1044 that it has to do with MDAC.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.