|
I have a free threaded out-of-process COM server that after the clients release the interface the COM server's CComModule::Unlock() returns a value > 0. After the client first releases, the return value of Unlock() is 1, after the client loads and releases the second time the value is 2, and this continues to increase by one as I startup and shutdown the client.
The client is using a smart pointer to the COM server interface. I also detached, the interface from the smart pointer in the destructor of my application and displayed the return value of Release() which is always 0. So it seems the client is releasing everything properly, it's just that the server isn't maintaining ref. count correctly for some reason. This causes the COM server to never shutdown. Any ideas why it keeps on increasing?
I turned on ATL debugging and came out with the following output in the trace window. I also display the return of Unlock() for the lines that begin with "Unlock count: X".
1> CComClassFactory - IUnknown
CComClassFactory - IUnknown
Loaded 'C:\WINDOWS\SYSTEM\RPCRT4.DLL', no matching symbolic information found.
2> CComClassFactory - IUnknown
1< CComClassFactory - IUnknown
1> CComClassFactory - IClassFactory
CComClassFactory - IClassFactory
1> CNREmail - IUnknown
CNREmail - IUnknown
2> CNREmail - IUnknown
CNREmail - IMarshal - failed
CNREmail - {0000001B-0000-0000-C000-000000000046} - failed
3> CNREmail - IUnknown
CNREmail - IUnknown
4> CNREmail - IUnknown
CNREmail - IStdMarshalInfo - failed
CNREmail - IExternalConnection - failed
3< CNREmail - IUnknown
Unlock count: 3
1> CNREmail - INREmail
CNREmail - INREmail
Loaded '[My app's Proxy server].dll', no matching symbolic information found.
1> CNREmail - INREmail
CNREmail - INREmail
2< CNREmail - IUnknown
Unlock count: 4
1< CNREmail - IUnknown
Unlock count: 3
0< CComClassFactory - IClassFactory
Loaded 'C:\WINDOWS\SYSTEM\MSVCRT.DLL', no matching symbolic information found.
Loaded 'C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll', no matching symbolic information found.
Loaded 'C:\Program Files\Common Files\SYSTEM\ole db\oledb32.dll', no matching symbolic information found.
Loaded 'C:\Program Files\Common Files\SYSTEM\ole db\oledb32a.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\msjint40.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\msjter40.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\mswstr10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\msjet40.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\msjetoledb40.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\MTXDM.DLL', no matching symbolic information found.
1> CNREmail - INREmail
CNREmail - INREmail
CNREmail - IMarshal - failed
CNREmail - {0000001B-0000-0000-C000-000000000046} - failed
2> CNREmail - IUnknown
CNREmail - IUnknown
1< CNREmail - IUnknown
Unlock count: 4
0< CNREmail - INREmail
Unlock count: 3
2> CNREmail - INREmail
The thread 0xFFF6F197 has exited with code 0 (0x0).
1< CNREmail - INREmail
Unlock count: 3
0< CNREmail - INREmail
Unlock count: 2
0< CNREmail - IUnknown
Unlock count: 1
Thanks in advance for any help!
- Pros
|
|
|
|
|
Also, when I startup and shutdown the client, the reference count that is returned via the ATL header debug interface traces always returns 1 after the client shutsdown and doesn't increase like the unlock count returned from CComModule::Unlock() which increases by 1 each time.
|
|
|
|
|
I figured it out. I had some worker threads in my COM server in which I was marshalling an interface pointer to itself, and had forgotten to call Release().
|
|
|
|
|
Hi guys,
Does anyone know what wrong I am doing?
CComPtr<ix> pIn;
CoCreateInstance(...)
... using pIn is fine ...
After that ...
_variant_t vIn(static_cast<iuknown*>(pIn));
... First chance exception???
I have already asked on codeguru... hasn't answer... Is here anyone who know?
Thanks for help.
|
|
|
|
|
I want to use IActiveDesktop in a program o create a random wallpaper changer. I get a pointer to IActiveDesktop (using CoCreateInstance), but when I try to use any Methods, I get the error message "Use of undefined type 'IActiveDesktop'". It then directs me to the declaration of IActiveDesktop in comdef.h. Can anyone help me use this.
Thanks
P.S. -> I don't want to use any MFC in the program. I'm using Win2K and VC++ 6.0.
Greg J. Hedlund
SuperStar
|
|
|
|
|
|
i use [in]short nSisze,[in,size_is(nSize)]byte* pBuffer,
or [in]short nSisze,[in,size_is(nSize)]byte pBuffer[],
but on the server i only get the first byte allocated in the client.
why???
Thanks in advance
|
|
|
|
|
This is just a guess since I'm a COM newbie, but if you created your ATL object with a "dual" interface then the above IDL won't work. You'll need to either use a VARIANT safearray to pass the data in, or create your object with a "custom" interface when you're on the ATL object wizard dialog.
Hope that helps,
Pros
|
|
|
|
|
Oh,thanks a lot .and also thanks for your reply in the previous message
I posted as cg.
I've tried again . I use
[in]short nSize,[in,size_is(nSize)]byte buffer[].
I found that it works both in the "dual" interface and custom interface .
But I don't know now why it failed before .a little confused
cg
|
|
|
|
|
Hello COM gurus
I'm trying to create a UI-less MFC ActiveX control that can be accessed from VBScript in an HTML page. I'm not using ATL because I want to minimize the possibility that the user's machine needs a restart. I've looked at MSDN's safectl tutorial which implements IObjectSafety to allow for scripting in hopes of getting some idea of what's going on. However, when I try to invoke a user-defined automation method in this control from VBScript, I get a "Catastrophic Error" (8000FFFF). This can't be good.
Can anyone suggest what I should look at/implement to expose methods to VBScript? Thanks for any suggestions.
|
|
|
|
|
Nevermind, I found the problem...See http://support.microsoft.com/support/kb/articles/Q146/1/20.ASP
|
|
|
|
|
I am trying to create a very simple com server, everything goes well until the last phase of the build process,
during the registration phase visual C++ freezes, I tried reinstalling VC++ but that did not help. Any ideas?
|
|
|
|
|
Are you on Win 9x? And running Norton AntiVirus? There's a known bug with NAV 2000 and 2001 on 9x which makes VC hang if you're running the Auto-Protect (background scanner) and do a build that makes VC launch another program in a custom build step (such as regsvr32 in an ATL project). Just disable AP (right-click the tray icon, pick Disable Auto-Protect) before doing your build.
Annoying, I know.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
i am daily facing this problem even thou any auto protect program is not running. After restart if kill both winoldap and Visual Studiofrom next on wards it freeze please help me.
|
|
|
|
|
Warning: COM newbie...
If I do all the code inline, no problems. Inside the function, everything works fine also. The moment it returns, pMyObj gets set to NULL (Like it's going out of scope?) What have I missed here, and how can I fix it such that I pass in a CComPtr and have it setup inside the function, but still valid outside the function (i.e. not reset to NULL)?
NB: Angle brackets converted to square brackets coz they were being treated as HTML.
BOOL DoStuff( CComPtr[IMyObj] pMyObj ); // Declaration
BOOL DoStuff( CComPtr[IMyObj] pMyObj ) // Definition
{
hr = pMyObj.CoCreateInstance( CLSID_MyObj );
if( FAILED( hr ) return FALSE;
return TRUE
}
void MyDlg::MyFunc( void )
{
CComPtr[IMyObj] pMyOutsideObj; // Usage
if( !DoStuff( pMyOutsideObj ) )
return;
}
|
|
|
|
|
The changes that DoStuff() makes to its parameter aren't reflected outside the function. This is how C function parameters work. You can fix your code by changing the parameter to a reference:
BOOL DoStuff ( CComPtr<IMyObj>& pMyObj );
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
Hi,
A project I am currently working on relies heavily on COM, connecting to remote servers etc... The system is in use for a few years now, and as part of "new" work on the project, we have to provide a "workaround" for calls to remote servers when they become incontestable i.e. an application\infrastructure component of the system holds a cached interface pointer to a component on server B, server B becomes disconnected from the network, and the application\infrastructure component attempts to make a call to that component. COM takes up to 15minutes to resolve the call and return an error, here in lies the problem.
The system has been in field for a few years now and is quite large, thus the workaround of determining if a server is contactable before each individual COM call is not a valid option. Some thought was put into getting down to the "COM" level i.e. proxy stub level. Has anyone had to workaround this problem before? Any ideas\help will be gratefully appreciated...
Cheers in advance,
Simon
|
|
|
|
|
I am beginner in C++. I am strugling with data type convertion. I am using ADO to get date data from DB. But problems start when I want to convert it and add it to ostringstream.
I am thankful for any hint.
date= pRsPtr->GetCollect(L"d_Date").date;
buffer<<""<
|
|
|
|
|
I want to know how to implement custom marshaling between machine and machine.but I can't find even one example anywhere.Can you offer me one?
Bill
Thank you all for your help!
|
|
|
|
|
Maybe this question is same to the last .Could anyone explain it to me?
::CoInitialize(NULL);
ISomeInterfacePtr ppv;
ppv.CreateInstance("MYSERVER.SOMEINTERFACE.1");
ppv->SomeFunction();
The code can be successful if the com object is in a dll .But failed
when the com object is in the exe-server .
I used ATL to create the exe-server project . Do I need to add additional
codes if it is created as an exe?
|
|
|
|
|
What is the error code when the object is in the exe-server? Did you register the proxy/stub for the exe server?
|
|
|
|
|
Thanks a lot . As I have no materials at hand now, I don't know what the error code means,which is a negative number .
But what do you mean that the proxy/stub need to be registered ?
After I compile and link the source code , the VC has helped me to register the exe-server .
I tried to create a dual interface in this Atl project ,and I found that I can use it in the client code . But if the interface was an custom interface which means it inherits from the IUnknown ,not IDispatch , I found the problem I posted last time .
Why?
|
|
|
|
|
For dual interfaces COM can use Automation(aka Unversal) marshaller and there is no need for separate proxy/stub dll. If you have custom interfaces and expect to the marshalling to be envolved (call the object methods from another apartment, in case of out-of-proc object this is always true), than you need to build and register proxy/stub dll. IDL compiler generates all necessary files for that and ATL wizard creates .def & makefile to build it (<yor projectname="">ps.def and <youprojectname>ps.mk.
Edward
|
|
|
|
|
If selected to create a custom interface, you'll need to register the proxy server marshalling dll for your EXE COM server. Look at the file with the WinMain(), Unlock(), and Monitor() functions that SCM uses to startup your COM server. At the top of the file you'll see some comments that look like this:
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f [Your EXE name here]ps.mk in the project directory.
Just do what it says. (NOTE: You may need to run vcvars32.bat in your VC directory to setup the paths to nmake and stuff.) After doing that you should have a proxy/server marshalling DLL file. You'll also need to register the DLL: regsvr32 [The newly created proxy/server]ps.dll
A way to automate this is to put it in your Project | Settings under the "Post-Build Step":
nmake /f MyComponent.mk
regsvr32 /c /s MyComponenetps.dll
- Pros
|
|
|
|
|
when I added the custom event in the dll-server ,which means the event interface inherits from IUnknown ,I can Advise using Sink-Object from the client code . But when the server is exe , Advise failed from the client code .Why?
|
|
|
|