Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am getting this error: "Act

Status
Not open for further replies.

tara8

Programmer
Nov 12, 2003
18
0
0
CA
I am getting this error:

"ActiveX component can't create object"

at this line of my code:

Set myObject = CreateObject("myProject.myClass", "myServerName")

(I've left out the real variable names).

Any ideas?

Also, my co-worker has the same code, only he's changed something in the object's interface and instead of getting the same error as me, he gets:

"Type mismatch"

More detail...

I'm trying to instantiate a class module that was compiled into an ActiveX DLL and registered as a COM component. Whenever I try to do this at the line of code that uses the CreateObject() function I get the "ActiveX component can't create object" error message ("Type mismatch" for my co-worker). The rest of the application works except for when I try to instantiate a certain class module that is new to the application. All other class modules are instantiated the same way, but for some reason a few new ones give me that error. We are using a 3-tiered application. I'm having problems accessing the 2nd tier from the 1st tier. And only for other machines than mine or my co-workers. This used to work (two weeks ago!), but just recently we've re-compiled the application and now it doesn't work.

I posted this in the Visual Basic 5.0/6.0 forum but so far no luck and I need a solution fast! Hopefully there's more results here in the COM forum.

This one is really frustrating!
 
on your machine the object could be not registered.
type
regsvr32 youractivex.xxx

Type mismath means someone do like this:

din xxx as MyActiveX.type
set xxx = CreateObject("MyActiveX....")
and at the same type your VB envirnoment does not have reference to this ActiveX. There are two ways to correct it
1. do not provide a type:
din xxx
set xxx = CreateObject("MyActiveX....")

2. Add reference to your ActiveX in your VB project. In VB window it should be in menu tools->references. If you still get this error, you should correct type in IDL from IDispatch* to some other type(if you have an IDL) and compile IDL again. IDispatch* is mapped in VB directly to Object.

If you have aa TLB file, would be great you to add reference from that .TLB. A tlb file is generated when you compile the .IDL.

Ion Filipski
1c.bmp
 
Yes, all you mentioned was done...

We fixed the problem... but still don't know why it had to be fixed that way...

We changed the project's compatibility to "Project", compiled it, then changed the project's compatibility back to "Binary", and replaced the copy of the dll. We had to do this for all projects that in the application that were affected.

Argh!?! Oh well... it's fixed.

Thanks for your input!
 
>why it had to be fixed that way...
ActiveX is very a complex technology. The computer deals with something binary and it knows nothing about your objects. Anyway, something happens and is very easy to believe what the computer knows something about your objects. I'm C++ programmer and I see big difference between dim xx as Object and dim xx as yourActiveX. The first one is based on dispinterfaces but the secont one support dual interfaces. So in the second case, you need to set a reference so what computer(saying comptuter I mean any programming environments you use) could know something about your object.


Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top