vb thin client mts/com problem???

i'm accessing my database thru mts/com - vb thin client. This was all working fine - i'd compile the client exe and run this on development machines and objects working fine. Now - after the last compile of mts objects some of the methods work and some dont e.g.

set object = new object.method1 WORKS
set object = new object.method2 FAILS with the following error:

Run-time error '-2147221163 (80040155':
Automation Error
Interface not registered

Now - mts exe was run on the webserver and the asp pages using the same objects and methods all work fine.
Any ideas?
Is there any way to be sure of a clean install of the mts com object references??

Who is Participating?
morgan_peatConnect With a Mentor Commented:
You did have binary compatibility set on your MTS objects, didn't you?

You compiled you MTS stuff again, after you compiled the client EXE.  That's all....

You've also got the object registered on the client machine?
On your dev machine it's OK, but you need to have it registered on other client machines, too.
Sometimes you need to unregister the component in MTS first, then register the new component again and add it to MTS. This is because MTS makes some kind of a copy of the available methods.

If you are using MTS, I would recommend using CreateObject instead of "As New".  CreateObject (on Win2k, at least) will work with MTS to create the object.  As New circumvents normal COM object creation, and can cause problems in MTS.
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Any documentation references about that? Using CreateObject is definitely slower!
It most certainly is slower, but CreateObject scales better.  Theres tons of documentation on it, almost everywhere you see a doc containing the words "visual basic" and "MTS".



The last one has the important paragraph "Important: Do not use the New operator, or a variable declared As New, to create an instance of a class that is part of the active project. In this situation, Visual Basic uses an implementation of object creation that does not use COM. To prevent this occurrence, it is recommended that you mark all objects passed out from a Visual Basic componentas Public Creatable, or its equivalent, and created with either the CreateObject function or the CreateInstance method of the ObjectContext object."
When you use the COM+ Services Type library in Win2k, it makes everything work with CreateObject.  If you are in pre-Win2k, you need to call GetObjectContext() and you need to use CreateInstance instead...  

Alright, read through the article. But as it said, you should NOT use it if you are creating a New instance of a class that is in the same project. For other items however (for example activex data objects) you'd better use it! :-/...that's how I read that article. It's good to know this info though, thnx!

I think you read the paragraph wrong.  It says you should not use "As New" for classes in the same project.

"Do not use the New operator, or a variable declared
As New, to create an instance of a class that is part of the active project"

Basically, it means don't ever use "As New" if you are planning on passing the object reference around.

From my own experience, I never use "As New" *ever* in a project meant to run under MTS.
When you're creating your first object (ie. one you know will start in MTS) then you can use New.  This is because VB is forced to go to the COM SCM to create the object.
Creating objects as New within the same project enables VB to bypass the SCM (It knows what the object is, so why go thru extra hoops to create it?  It's quicker just to instantiate it internally).  This is why it's dangerous to use New for objects in the same project.

A good way (in fact, one in the Wrox MTS/VB book) is to check the Activation status thru the ObjectControl interface.
ie. Store ObjectContext at module-level (via Active/Deactivte events).  Also store a m_bIsMTS boolean with this.

If m_bInMTS Then
    Set o = m_oContext.CreateInstance(blah..)
    Set o = New blah....
End If

Best of both worlds, then :-)
Hi richkeegan,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Split points between: morgan_peat and CJ_S and anthony_glenwright

richkeegan, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer
Points reduced for split and comment accepted as answer.  The other experts can look for their question in this topic area

E-E Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.