Scattan
asked on
MTS Component
Hi!
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)
Thanks!
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)
Thanks!
ASKER
OK, in the component project this is what the .idl file looks like:
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(13CD935D-B797-11D3-B2 38-00104B9 2E298),
dual,
helpstring("Itest Interface"),
pointer_default(unique)
]
interface Itest : IDispatch
{
[id(1), helpstring("method RunTest")] HRESULT RunTest();
};
[
uuid(13CD9351-B797-11D3-B2 38-00104B9 2E298),
version(1.0),
helpstring("testCleaner 1.0 Type Library")
]
library TESTCLEANERLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(13CD935E-B797-11D3-B2 38-00104B9 2E298),
helpstring("test Class")
]
coclass test
{
[default] interface Itest;
};
};
And this is what the function looks like:
STDMETHODIMP Ctest::RunTest()
{
Beep(1000,1000);
return S_OK;
}
The test-class is declared like this:
class ATL_NO_VTABLE Ctest :
public CComObjectRootEx<CComSingl eThreadMod el>,
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:
::CoInitialize(NULL);
CLSID clsID;
CComBSTR str("TestCleaner.test");
CLSIDFromProgID(str,&clsID );
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";
t->Release();
(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!
import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(13CD935D-B797-11D3-B2
dual,
helpstring("Itest Interface"),
pointer_default(unique)
]
interface Itest : IDispatch
{
[id(1), helpstring("method RunTest")] HRESULT RunTest();
};
[
uuid(13CD9351-B797-11D3-B2
version(1.0),
helpstring("testCleaner 1.0 Type Library")
]
library TESTCLEANERLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(13CD935E-B797-11D3-B2
helpstring("test Class")
]
coclass test
{
[default] interface Itest;
};
};
And this is what the function looks like:
STDMETHODIMP Ctest::RunTest()
{
Beep(1000,1000);
return S_OK;
}
The test-class is declared like this:
class ATL_NO_VTABLE Ctest :
public CComObjectRootEx<CComSingl
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:
::CoInitialize(NULL);
CLSID clsID;
CComBSTR str("TestCleaner.test");
CLSIDFromProgID(str,&clsID
IUnknown* pUnk;
if (CoCreateInstance(clsID, NULL, CLSCTX_ALL, IID_IUnknown, (LPVOID *)&pUnk) != S_OK)
return S_FALSE;
Itest* t;
if (pUnk->QueryInterface(IID_
return S_FALSE;
if (t->RunTest() != S_OK)
cout<< "fel";
t->Release();
(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:
delayimp.lib
and the following switch to the end of the project options
text box in the link tab:
/delayload:mtxex.dll
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.
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:
delayimp.lib
and the following switch to the end of the project options
text box in the link tab:
/delayload:mtxex.dll
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.
ASKER
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>It says something about the function ZwReplyWaitReceivePort
"Zw" functions are part of the kernel so there's something seriously wrong - don't know what.
Glenn
ASKER
Thanks!
Regards