Solved

MTS-friendly Components vs Simple Objects???

Posted on 2000-05-12
2
253 Views
Last Modified: 2010-08-05
CASE 1:I create a new VC++ project and make it MTS-friendly and then create my ATL's as MTS-components.
CASE 2: I create a new VC++ project without making it MTS-friendly and then create my ATL's as Simple Objects.

Question : What's the differences between the two? I've noticed the following in the MTS-friendly proj:

In the .dsp "ADDLINK 32...mtx.lib mtxguid.lib delayimp.lib...delayload:mtxex.dll"

In all of the .rgs the threadingmodel is set to 'Both'.

Are there any other differences?
Would it be possible to convert a non-MTS-friendly project to a friendly one just by making these changes or do I have to rewrite the whole thing?

A detailed answer is very much appreciated, thanks

Kattis
0
Comment
Question by:Kattis
2 Comments
 

Author Comment

by:Kattis
ID: 2813438
Adjusted points from 150 to 250
0
 
LVL 1

Accepted Solution

by:
kanejin earned 250 total points
ID: 2841380
Dear Kattis,

In ATL Wizard there are 2 places you can select MTS.

1. "Support MTS" in "AppWizard Step 1 of 1"
If you choose this option, the Appwizard will add mtx.lib, mtxguid.lib and delayimp.lib these static libraries to the project. You can find them in Project->Settings->Link. In addition, this option adds a reminder in the registration build step to run mtxrereg.exe before using the component in MTS. You can find this in Project->Settings->Custom Build. delayimp.lib is used to allow your project to Delay Load the mtxex.dll. Delay Load which is a new feature in VC6 allows you to specify a list of Dlls that will only be loaded when they are actually called. You may find a new link option "/delayload:mtxex.dll" in Project->Settings->Link.

2. "MS Transaction Server Component" in ATL Object Wizard
If you choose "MS Transaction Server Component" when you create a new object, "mtx.h" will be included.If you choose "Support IObjectControl", your object will implement IObjectControl(your object class will derive from IObjectControl).The following lines are added to the bottom of your class:

// IObjectControl
public:
STDMETHOD(Activate)();
STDMETHOD_(BOOL, CanBePooled)();
STDMETHOD_(void, Deactivate)();
CComPtr<IObjectContext> m_spObjectContext;

(Of course these methods' implementation code is added to the cpp file)
So you do not need rewrite the whole project. MTS component is also a com component.
Enjoy them.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

929 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

13 Experts available now in Live!

Get 1:1 Help Now