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?
IexpertConnect With a Mentor Commented:
Mail the drwatson.log to
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!

The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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

>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:
All Courses

From novice to tech pro — start learning today.