[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

vb thin client mts/com problem???

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
richkeegan
Asked:
richkeegan
  • 4
  • 4
  • 2
  • +2
1 Solution
 
morgan_peatCommented:
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
 
CJ_SCommented:
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
 
anthony_glenwrightCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
CJ_SCommented:
Any documentation references about that? Using CreateObject is definitely slower!
0
 
anthony_glenwrightCommented:
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
 
anthony_glenwrightCommented:
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
 
CJ_SCommented:
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
 
anthony_glenwrightCommented:
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
 
CJ_SCommented:
Hmmmm....
0
 
morgan_peatCommented:
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
 
DanRollinsCommented:
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
 
Computer101Commented:
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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 4
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now