[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

vb thin client mts/com problem???

Posted on 2001-06-07
12
Medium Priority
?
534 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 1

Accepted Solution

by:
morgan_peat earned 268 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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
 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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