Solved

vb thin client mts/com problem???

Posted on 2001-06-07
12
518 Views
Last Modified: 2013-11-25
Hi,
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
BUT
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??
Cheers,
Rich

0
Comment
Question by:richkeegan
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 1

Accepted Solution

by:
morgan_peat earned 67 total points
ID: 6163070
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.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6163108
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.

regards,
CJ
0
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6163909
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.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6166704
Any documentation references about that? Using CreateObject is definitely slower!
0
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6166729
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".

http://msdn.microsoft.com/library/devprods/vs6/vbasic/vbcon98/vbconhowobjectcreationworksinvbcomponents.htm
http://msdn.microsoft.com/library/periodic/period99/basics0899.htm

http://msdn.microsoft.com/library/psdk/mts20sp1/mtxpg04_0eb7.htm

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."
0
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6166738
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...  

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 22

Expert Comment

by:CJ_S
ID: 6166764
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!

Regards,
CJ
0
 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6166771
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.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6166774
Hmmmm....
0
 
LVL 1

Expert Comment

by:morgan_peat
ID: 6166926
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.

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


Best of both worlds, then :-)
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7133401
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
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7167911
Points reduced for split and comment accepted as answer.  The other experts can look for their question in this topic area

Computter101
E-E Moderator
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now