Solved

ATL COM connection point from worker thread not working with .NET client

Posted on 2008-06-19
7
732 Views
Last Modified: 2013-12-05
In the past I have written ATL COM dlls with visual studio 6 using connection points to communicate with VB6 clients.  The dll has a worker thread that fires the connection point back to the Windows XP VB6 client app.  When I port this to VS2005 and the client is now .NET on the CE 5.0 platform the connection point does not fire in the client app.

I know the connection point works because I have fired it from the dll and the client gets it.  But when the worker thread does it the client does not see it.  Any idea as to what the difference could be that is making this fail?

thanks.
 
0
Comment
Question by:tkamrath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
7 Comments
 
LVL 5

Expert Comment

by:JuckMan
ID: 21833484
Connection points are created for the ATL/COM world. When you port this to .NET can you convert this to an event pub/sub model. This is easy to code and maintain.

Also I am not clear on when it work and when it fails. Could you eloborate on your following statement..

"I know the connection point works because I have fired it from the dll and the client gets it.  But when the worker thread does it the client does not see it. "


0
 

Author Comment

by:tkamrath
ID: 21833954
I have implemented the event object on the .NET side and added the pointer to the object connection point table.  here is the code that does this.

        public atlcomCELib.testerClass mytest;

        // this class is required to create the COM event handler routines
        // in such a way that they can be registered with the ATL COM dll.
        public class ManagedSink : _ItesterEvents
        {
            public Form1 Parent;

            public void OnTestOneDone(int status)
            {
                int y;
                float z;
                y = status;
                z = Parent.mytest.outp;
            }
        };

       
        private void Form1_Load(object sender, EventArgs e)
        {
            ManagedSink ms = new ManagedSink();
            ms.Parent = this;
            mytest = new atlcomCELib.testerClass();

            // this registers the handler routine with the ATL COM dll.
            // so when an event is fired from the dll this handler routine is run.
            mytest.OnTestOneDone += ms.OnTestOneDone;

            mytest.testOne(12345);
        }

When I fire the event from the ATL COM object via the mytest.testOne method it works fine.  But when the worker thread that the object creates fires the event it does not work.  And as I said, this architecture works in windows XP with VB6 as the client.  The worker thread code  is as follows :

void Ctester::FireDoneEvent()
{
      Fire_OnTestOneDone (2);
}

DWORD WINAPI Ctester::ThreadRoutine (LPVOID data)
{
   // put the thread into a MTA so that it does not block the main thread.
   CoInitializeEx (NULL, COINIT_MULTITHREADED);
   
   // get a pointer to the Modbus wrapper class for access to data.
   Ctester *me = (Ctester *)data;

   me->FireDoneEvent ();

   // release the thread from the MTA thread pool.
   CoUninitialize();

   return 0;
}

0
 

Author Comment

by:tkamrath
ID: 21854943
I have discovered an additional symptom.

When I step through the proxy routine that looks up the client handler routine in the table I get a failure on the pConnection->Invoke call.  The error is -2147352567 or 80020009.  Again, this only happens when the proxy is called from the worker thread via a method in the object.

worker thread calls object method which then calls the proxy function.  The object is registered for the FREE threading model.  So I believe that the worker thread and the object are in the MTA.
0
 

Author Comment

by:tkamrath
ID: 21866109
More input on this problem.

I built a .NET client to run on the PC with the VS 6.0 version of the ATL COM dll.  It works.

So, my dll works on the PC with a VB6 or a .NET client.

I now only see two variables to this problem.
1)  built with new version of tool, VS2005.
2)  Running on CE platform, which may mean that the ATL is limited or buggy or...

My guess is it is ATL in CE.  Any ideas?
thanks.
0
 

Accepted Solution

by:
tkamrath earned 0 total points
ID: 22034953
You can close this one.  I have gone to MS about this.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Server 2003 2 43
XENAPP 6.5 quastion isssue after install micrsoft patch for Wannacry 7 49
Windows 10 14 37
RDP exploit 13 19
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question