|
In a ATL project I have a coclass CMonitorClt with an outgoing interface called _IMonitorCltEvents with a method called DataReceived([in] BSTR Key, [in] BSTR Data).
The coclass creates a thread (receiver-thread) that is responsible for receiving something on a socket and fireing an event on the outgoing interface.
The coclass have a ATL-generated Fire_DataReceived(BSTR Key, BSTR Data) method that can be called to fire an event in the client. To make Fire_DataReceived() available to the receiver-thread I have passed a reference to the coclass in CreateThread(). When I call the Fire_DataReceived function from the receiver-thread the client (VB6) crashes - Dohh.
I think I know what the problem is - the outgoing interfacepointer needs to be marshalled between the main-thread and the receiver-thread with CoMarshalInterThreadInterfaceInStream() and CoGetInterfaceAndReleaseStream() in order to call a method on the interface. But can this be done? The interfacepointers are held and managed by the coclass (derived from IConnectionPointImpl) and the receiver-thread knows nothing about these interfacepointers and when they should be marshalled.
How can I use ConnectionPoint and fire an event on a connectionpoint from a thread that is not a main-thread?
Søren Randrup
|
|
|
|
|
The most simple way to do this is use MTA (Multiple Thread Apartment) in your COM Object.
Also make sure that you are using ::CoInitializeEx(...) and ::CoUnitialize() in each thread that you have created.
This loads the OLE libarary for each thread, this is required if you are using COM Objects in the Threads
|
|
|
|
|
What's wrong with the convertion?:
CComVariant varStrRet(ostrBuffer.str().c_str());
ostrBuffer is ostringstream. Everithing works fine but if I load more then aprox. 500Kb into ostrBuffer the the convertion result in access violetion. Enyone knows why?
Thanks a lot for any help
Peter
|
|
|
|
|
I'm trying to learn Visual C++ but I've the problem that everytime I get the typical window-crash-nobody-knows-why and I restore my computer, the project browser doesn't display anything and I get the message above.
Could somebody tell me how to restore the classview information file?
Thanks.
|
|
|
|
|
For Classview
Before opening Visual Studio, delete the myProject.ncb file
Where myProject is the name of your project.
For ClassWizard
Delete the myProject.clw file
Both these files will be rebuilt for you.
|
|
|
|
|
Hi
I queried for a interface pointer in a constructor and want to use it across
several functions.I need that pointer in many functions but dont know where to release it and how to do it?Can I release it in destructor of the class in which i queried and using?
Please help me
Thanks
Pathi
bhikshapathi_g@semanticspace.com
|
|
|
|
|
From your general description I would say releasing the interface pointer in the destructor would be sufficient.
|
|
|
|
|
I wrote an ATL NT service? i want to use CPtrlist class,but the project doesn't support MFC?How can i
add such support?
|
|
|
|
|
Why burdon yourself, and your code, with adding MFC? Why not just use and STL container such as a list, deque, etc.?
|
|
|
|
|
1. Link in the MFC libraries (either static or dynamic) using the project settings wizard.
2. Add #include <afxdisp.h> to StdAfx.h atter the #define STRICT line...
You must be using VC 6 for this to work. If using earlier versions its a little harder. MSDN has an article. "How to add MFC to ATL...
Here's is a snip from one of mine.
#define STRICT
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#include <afxdb.h>
#include <afxdisp.h>
#define _ATL_FREE_THREADED
#include <atlbase.h>
Thanks for the help,
Bill
|
|
|
|
|
I want to use VB COM+ DLL from C++ console application or C application and not to lose COM+ functionality (JIT, scalability...), I managed to call it from C++ console application but only when component is registered like librabry application, when component is registerd like server application I
get following error when creating object :
'creating object
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER ,__uuidof(_cFMlogic),
(LPVOID *) &t);
'error
hresult= -2147221164, Class not registered
|
|
|
|
|
Hello,
I have some problems with the registration of my NT service.
When I register the service as an DCOM server, I can not specify
my remote server with his IP address but only with his network
name but when I register the same component as a NT service,
the IP address and the network name work.
Has anybody already met this kind of problem ?
Thanks by advance.
|
|
|
|
|
Hi,
I've been having real trouble getting to grips with how to package in a cab file and sign a active x control for use in a web page.
I have all the componets i need (i think)
a .ocx , .spc , .pvk and a .ini that i have made which seems to be correct becuase i can use it in a web page to setup the active x control.
but i have used the cabarc.exe tool, but i can't then embed it in a web page as the codebase item, IE just starts to open the page, then the icon turns to an X, and thats it, no error message.
Any help or guidance would be real helpful,
Thanks.
|
|
|
|
|
Hi,all
I want to install com+ applications and web site in my setup program.Then how to do in install shield?
sandos
|
|
|
|
|
Hi all,
What is difference between E_FAIL and S_FALSE ???
Thanks for helps ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
E_FAIL (0x80004005) indicates, that the function fails. No further processing is possible (e.g. an object cannot be instanciated). Script languages are throwing exceptions in this case.
S_FALSE (0x00000001) indicates, that the function has no effect or has no results. In script languages no exception will occur.
Volker
|
|
|
|
|
These can also be used to inform of fatal and non-fatal errors.
S_FALSE may be returned from a method when it partially succeeded. For example numbers were calculated correctly but were of insufficient range.
HRESULT Calculate(int x, int y)
{
if( x > 5000 || y > 5000)
return E_FAIL; // return failure because these numbers are greater than
// possible range expected
if( (x + y) < 500 )
return S_FALSE; // return false because it worked but just wasn't high enough
else
return S_OK;
}
|
|
|
|
|
E_FAIL will also throw an exception if you use Visual Basic, and S_FALSE will not.
|
|
|
|
|
I am using an asynchronous property in my ActiveX control to implement the background of my control.
What should I do to implement the property?
Is there any articles about the topic?
Thanks.
Maer
|
|
|
|
|
Why use the statement "EnableCompoundFile()" in the function "CMyServerDoc::CMyServerDoc"? Here, "CMyServerDoc" is a class derived from the class "COleServerDoc". My application is a MDI based server application.
Does it have anything to do with "COleServerItem"?
|
|
|
|
|
In a com application, I am putting a vector in a varinat , and sending it. I have problems while retreiving the vector from variant. Can u suggest some solution to this.
Thanks
Madhavi.
|
|
|
|
|
Check this variant and safearray sample by Ron Jacobs
http://www.sellsbrothers.com/tools/CComSafeArray.zip
It may help you out, as I really did not understand the vector bit !!!
|
|
|
|
|
In a com application, I am putting a vector in a varinat , and sending it. I have problems while retreiving the vector from variant. Can u suggest some solution to this.
Thanks
Madhavi.
|
|
|
|
|
Hey,
I wanted to send DISPARMS as the return argument in one of the COM method.
Can u suggest some solution to this.
Thanks
|
|
|
|
|
I want to release memory in com when i need to do it. I don't want the system to do it. How can i implement it?
|
|
|
|