MTS Component


Does anyone know why I have this problem:
I have made a component, with ATL and C++, just a simple ATL project with one simple object with one function without parameters. When I register this component in the Ms. Transaction Server, I get an "Abnormal Termination" or an access violation when I run the function, but if i register the component with regsvr32, it works fine.
Why is this?
I've allready got another project with several components that works fine in the MTS, but this one doesnt! (But I didn't create the project that works, so I don't know the difference between them)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How about some code? which can give us more light to search?
ScattanAuthor Commented:
OK, in the component project this is what the .idl file looks like:

import "oaidl.idl";
import "ocidl.idl";
            helpstring("Itest Interface"),
      interface Itest : IDispatch
            [id(1), helpstring("method RunTest")] HRESULT RunTest();

      helpstring("testCleaner 1.0 Type Library")

            helpstring("test Class")
      coclass test
            [default] interface Itest;

And this is what the function looks like:


      return S_OK;

The test-class is declared like this:
class ATL_NO_VTABLE Ctest :
      public CComObjectRootEx<CComSingleThreadModel>,
      public CComCoClass<Ctest, &CLSID_test>,
      public IDispatchImpl<Itest, &IID_Itest, &LIBID_TESTCLEANERLib>

(Its all generated by the wizard)

When I use the object I do like this in the test-application:


    CLSID clsID;
    CComBSTR str("TestCleaner.test");

     IUnknown* pUnk;
    if (CoCreateInstance(clsID, NULL, CLSCTX_ALL, IID_IUnknown,  (LPVOID *)&pUnk) != S_OK)
      return S_FALSE;

     Itest* t;
     if (pUnk->QueryInterface(IID_IDispatch, (LPVOID *)&t) != S_OK)
            return S_FALSE;

       if (t->RunTest() != S_OK)
             cout<< "fel";

(After importing TestCleaner.dll)

This works as long as I  don't use the transaction server.
When I create the project, it doesn't matter if I check "Support MTS" or not, there is still the same problem.
Is this the part of the code you need to see or should I give you something else?
Thanks for trying to help!

You need to link in the following

mtx.lib mtxguid.lib

i.e. add these 2 libs to the list @
Project settings/Link tab/General Category/Obj/lib modules

For efficiency also add the following to the list:
and the following switch to the end of the project options
text box in the link tab:

Note should also do following after a build
and before using MTS components in MTS.
Execute MTXREREG.exe to refresh all components
registered on your computer. This is the command-line
version of the Refresh Components option that you can
access by right-clicking on a selected package.
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

ScattanAuthor Commented:
Thanks, but all that is allready done.
All the .libs and .dlls you suggested are included in the project, so the problem is something else.

There is an error log generated in drwtsn32.log, but I really don't know how to read it.
It says something about the function ZwReplyWaitReceivePort and NtDelayExecution, and the last executions before logging the error are these:
227 mmc.exe
 485 mtx.exe
 453 CMD.exe
  74 RunTestCleaner.exe   //my test-app
 483 mtx.exe
 436 DRWTSN32.exe
   0 _Total.exe

Thanks anyway.
Other suggestions?
Mail the drwatson.log to

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

>It says something about the function ZwReplyWaitReceivePort

"Zw" functions are part of the kernel so there's something seriously wrong - don't know what.
ScattanAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.