Here's my situation, I am moving some of my apps over from native C++
(primarily Win32 and MFC).
One of these apps uses some COM objects in worker threads running in the
background where it doesn't bother the user.
I'm keeping the native code that interfaces with the COM objects in a DLL
since I know it works with no problem (I've used for a year and half with no
bugs).
I want my .Net app to use those exported functions (from the above mentioned
DLL) from within child threads.
The problem I'm getting is that when my native code calls CoCreateInstance()
to get the interface, it returns E_NOINTERFACE. But only if my native code
is being called from within a child thread. I've tried just simply calling
it from a button push on a form, and it works perfectly.
Is there some kind of setting I need to set in the Thread object? I've
tried changing the apartment to MTA (from the defaul unknown). Is there some
other setting I'm missing?
thank you so much in advance,
ed 3 3122
Do you call CoInitialize to init the COM library in your threads?
-Atul http://www.ssware.com/
Shell MegaPack - Windows Explorer Shell Controls for ActiveX and .Net
"Ed" <Ed@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com... Here's my situation, I am moving some of my apps over from native C++ (primarily Win32 and MFC).
One of these apps uses some COM objects in worker threads running in the background where it doesn't bother the user.
I'm keeping the native code that interfaces with the COM objects in a DLL since I know it works with no problem (I've used for a year and half with no bugs).
I want my .Net app to use those exported functions (from the above mentioned DLL) from within child threads.
The problem I'm getting is that when my native code calls CoCreateInstance() to get the interface, it returns E_NOINTERFACE. But only if my native code is being called from within a child thread. I've tried just simply calling it from a button push on a form, and it works perfectly.
Is there some kind of setting I need to set in the Thread object? I've tried changing the apartment to MTA (from the defaul unknown). Is there some other setting I'm missing?
thank you so much in advance, ed
No,
I'm using AfxOleInitModule() in the InitInstance() implementation since the
native dll is MFC based. According to the docs this is what I understood to
be the best practice.
I just tried switching to trying to using CoInitialize, and there was no
difference. I also tried getting just the IUnknown interface of the CLSID,
and that works ok. But when I try a QI on the IUnknown pointer for the
interface that I'm actually trying to get, it's the same thing all over again
(E_NOINTERFACE).
ed
"Atul" wrote: Do you call CoInitialize to init the COM library in your threads?
-Atul http://www.ssware.com/ Shell MegaPack - Windows Explorer Shell Controls for ActiveX and .Net
"Ed" <Ed@discussions.microsoft.com> wrote in message news:54**********************************@microsof t.com... Here's my situation, I am moving some of my apps over from native C++ (primarily Win32 and MFC).
One of these apps uses some COM objects in worker threads running in the background where it doesn't bother the user.
I'm keeping the native code that interfaces with the COM objects in a DLL since I know it works with no problem (I've used for a year and half with no bugs).
I want my .Net app to use those exported functions (from the above mentioned DLL) from within child threads.
The problem I'm getting is that when my native code calls CoCreateInstance() to get the interface, it returns E_NOINTERFACE. But only if my native code is being called from within a child thread. I've tried just simply calling it from a button push on a form, and it works perfectly.
Is there some kind of setting I need to set in the Thread object? I've tried changing the apartment to MTA (from the defaul unknown). Is there some other setting I'm missing?
thank you so much in advance, ed
Why don't you try calling Application.OleRequired from your child thread?
-Atul http://www.ssware.com/
Shell MegaPack - Windows Explorer Shell Controls for ActiveX and .Net
"Ed" <Ed@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com... No, I'm using AfxOleInitModule() in the InitInstance() implementation since the native dll is MFC based. According to the docs this is what I understood to be the best practice.
I just tried switching to trying to using CoInitialize, and there was no difference. I also tried getting just the IUnknown interface of the CLSID, and that works ok. But when I try a QI on the IUnknown pointer for the interface that I'm actually trying to get, it's the same thing all over again (E_NOINTERFACE).
ed
"Atul" wrote:
Do you call CoInitialize to init the COM library in your threads?
-Atul http://www.ssware.com/ Shell MegaPack - Windows Explorer Shell Controls for ActiveX and .Net
"Ed" <Ed@discussions.microsoft.com> wrote in message news:54**********************************@microsof t.com... > Here's my situation, I am moving some of my apps over from native C++ > (primarily Win32 and MFC). > > One of these apps uses some COM objects in worker threads running in > the > background where it doesn't bother the user. > > I'm keeping the native code that interfaces with the COM objects in a > DLL > since I know it works with no problem (I've used for a year and half > with > no > bugs). > > I want my .Net app to use those exported functions (from the above > mentioned > DLL) from within child threads. > > The problem I'm getting is that when my native code calls > CoCreateInstance() > to get the interface, it returns E_NOINTERFACE. But only if my native > code > is being called from within a child thread. I've tried just simply > calling > it from a button push on a form, and it works perfectly. > > Is there some kind of setting I need to set in the Thread object? I've > tried changing the apartment to MTA (from the defaul unknown). Is > there > some > other setting I'm missing? > > thank you so much in advance, > ed This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jean-Yves Nief |
last post by:
hello,
I have written a script which is performing some tasks in
multithreading mode: the main thread is opening a connection to a
distant server and all the threads that I start will have to...
|
by: dixp |
last post by:
I'm new to writing multithreaded apps and I have a design question. I
have a winforms app and a class which has a method that does processing
which is time intensive. I want the user to be able...
|
by: Mark Yudkin |
last post by:
The documentation is unclear (at least to me) on the permissibility of
accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003,
with separate transactions scope, from separate...
|
by: Jeff Yang |
last post by:
These days,I have read the artile "Safe, Simple Multithreading in Windows
Forms, Part 1" on MSDN,and I also runed the example of it....
|
by: Silent Ocean |
last post by:
Hi All
I have following questions regarding C# Assembly and Threading.
Let me know the precise answer or lead me to the proper materials.
1. Is memory leakeage possible in .Net Manager...
|
by: sarge |
last post by:
I would like to know how to perform simple multithreading.
I had created a simple form to test out if I was multithreading
properly, but got buggy results. Sometime the whole thig would lock
up...
|
by: SStory |
last post by:
Here is the situation.
I want to display Icons, Type of file etc from a file extension.
Upon initial program load I may only need icons for certain files. But
other operations will require...
|
by: Rich |
last post by:
Hello,
I have set up a multithreading routine in a Test VB.net
proj, and it appears to be working OK in debug mode and I
am not using synchronization. Multithreading is a new
thing for me, and...
|
by: sandy82 |
last post by:
Whats actuallly multithreading is ... and how threading and
multithreading differ .
Can any1 guide how multithreading is used on the Web .. i mean a
practical scenario in which u use...
|
by: Ray |
last post by:
Hello,
Greetings! I'm looking for a solid C++ multithreading book. Can you
recommend one? I don't think I've seen a multithreading C++ book that
everybody thinks is good (like Effective C++ or...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |