Click here to Skip to main content
15,922,584 members
Home / Discussions / COM
   

COM

 
QuestionCOM/ACTIVE X/OLE Pin
Cmania9-Jan-07 18:51
Cmania9-Jan-07 18:51 
AnswerRe: COM/ACTIVE X/OLE Pin
CPallini10-Jan-07 20:20
mveCPallini10-Jan-07 20:20 
AnswerRe: COM/ACTIVE X/OLE Pin
User 21559711-Jan-07 0:08
User 21559711-Jan-07 0:08 
QuestionVARIANT_BOOL return value in Automation class Pin
User 2155979-Jan-07 5:07
User 2155979-Jan-07 5:07 
AnswerRe: VARIANT_BOOL return value in Automation class Pin
Roger Stoltz9-Jan-07 5:45
Roger Stoltz9-Jan-07 5:45 
QuestionRe: VARIANT_BOOL return value in Automation class [modified] Pin
User 2155979-Jan-07 5:52
User 2155979-Jan-07 5:52 
AnswerRe: VARIANT_BOOL return value in Automation class Pin
Roger Stoltz9-Jan-07 21:18
Roger Stoltz9-Jan-07 21:18 
QuestionRe: VARIANT_BOOL return value in Automation class Pin
User 21559710-Jan-07 0:26
User 21559710-Jan-07 0:26 
Roger Stoltz wrote:
I would really like to see the declarations in the .odl, .h and the wizard generated header file for the client.

SERVER code is below -
dispinterface ISomeInterface<br />
	{<br />
		properties:<br />
		methods:<br />
		[id(1), helpstring("")] void Start(BSTR str);<br />
        [id(2), helpstring("")] VARIANT_BOOL IsWorking();<br />
    };


Start actually starts an asynchronous activity on the server. I use IsWorking method to determine whether the activity is over or not. In my client, when a request is recieved for another "start", I need to check whether the Server is already working, if yes, then I need to wait in my client. Server notifies the Client about activity completion through COM event source/sink mechanism. So in short, IsWorking determine whether the client should wait or not before issuing any requests

In Server's SomeInterface.H file, following is the declaration
void Start(LPCTSTR str);<br />
VARIANT_BOOL IsWorking();


Client code generated by Wizard -
void Start(LPCTSTR str)
{
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x1, DISPATCH_METHOD, VT_EMPTY, NULL, parms, str);
}
BOOL IsWorking()
{
BOOL result;
InvokeHelper(0x2, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);
return result;
}


Roger Stoltz wrote:
This rings a bell quite loudly... I've seen this problem before, but I cannot remember what the solution was.
I have a vague memory that it was really about the mixup of boolean types and marshalling.

While Googling for hours, I got this thread which is similar but the Class and file in talk though similar, is different. Check following thread -
http://groups.google.com/group/microsoft.public.vc.mfc/browse_thread/thread/fa6cffd879ac26da/1564231c27c4667a?lnk=st&q=V_BOOL(&rnum=10#1564231c27c4667a[^]

Roger Stoltz wrote:
Can you describe the relationship between your server and client a little bit further? EXE-server? Threads? The need for marshalling?
The name IsWorking suggests that it could be multithreaded...


The EXE server is created in MFC and it has exposed SomeInterface class which is CoCreatable. The Client could be any client, I have -
1. ActiveX component which is client to my server. And this control is placed inside C# application. ActiveX component is written in MFC
2. I have created a Simple MFC EXE with FormView, which directly calls the methods of the EXE server. This is did just to ensure there is not threading or marshalling issue because of Managed C# code. But the problem occurs in both the Managed client with ActiveX control or Unmanaged client

The coclass has no threads. The Exe server is multithreaded but the coclass Start method simply delegates the call there.
My clients are single threaded.
Regarding marshalling, I believe standard marshalling should take care of this because i am using the OleAutomation compatible type.
Everything works fine for Start method and I succesfully get the "BSTR" from my clients hence I see no issue about marshalling.

To me it seems like a bug some problem as discussed on the thread I have mentioned above. I think the problem is somewhere in IDispatch::Invoke code. I should avoid calling it a bug till I am sure about this Smile | :)

As of now, I have converted the return type to LONG and everything is working fine. I can proceed further on the original code. I have created a sample application which I can use to diagnose this issue with you side-by-side.



S o h a i l K a d i w a l a

To Err Is Human; to Debug, Divine


modified 21-Apr-21 21:01pm.

AnswerRe: VARIANT_BOOL return value in Automation class Pin
Roger Stoltz10-Jan-07 2:42
Roger Stoltz10-Jan-07 2:42 
GeneralRe: VARIANT_BOOL return value in Automation class Pin
User 21559711-Jan-07 0:03
User 21559711-Jan-07 0:03 
GeneralRe: VARIANT_BOOL return value in Automation class Pin
Roger Stoltz11-Jan-07 0:46
Roger Stoltz11-Jan-07 0:46 
GeneralRe: VARIANT_BOOL return value in Automation class [modified] Pin
User 21559711-Jan-07 5:03
User 21559711-Jan-07 5:03 
AnswerRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
User 21559711-Jan-07 6:07
User 21559711-Jan-07 6:07 
GeneralRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
Roger Stoltz11-Jan-07 22:45
Roger Stoltz11-Jan-07 22:45 
GeneralRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
User 21559712-Jan-07 0:50
User 21559712-Jan-07 0:50 
GeneralRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
Roger Stoltz12-Jan-07 1:50
Roger Stoltz12-Jan-07 1:50 
GeneralRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
User 21559712-Jan-07 4:11
User 21559712-Jan-07 4:11 
GeneralRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
Roger Stoltz12-Jan-07 4:40
Roger Stoltz12-Jan-07 4:40 
GeneralRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
User 21559712-Jan-07 5:24
User 21559712-Jan-07 5:24 
GeneralRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
Roger Stoltz12-Jan-07 5:37
Roger Stoltz12-Jan-07 5:37 
GeneralRe: [SOLVED] VARIANT_BOOL return value in Automation class Pin
User 21559714-Jan-07 7:50
User 21559714-Jan-07 7:50 
QuestionCOM and windows service application ... Pin
Sakthiu9-Jan-07 0:31
Sakthiu9-Jan-07 0:31 
QuestionHow can get information from web page ? Pin
ankprasanna9-Jan-07 0:22
ankprasanna9-Jan-07 0:22 
QuestionCOM dll internals. Pin
HakunaMatada8-Jan-07 19:21
HakunaMatada8-Jan-07 19:21 
AnswerRe: COM dll internals. Pin
Phil Harding15-Jan-07 3:45
Phil Harding15-Jan-07 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.