Click here to Skip to main content
16,007,809 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: fatal error LNK1112 Pin
Richard MacCutchan21-Apr-11 6:42
mveRichard MacCutchan21-Apr-11 6:42 
GeneralRe: fatal error LNK1112 Pin
Walking Hell21-Apr-11 7:07
Walking Hell21-Apr-11 7:07 
GeneralRe: fatal error LNK1112 Pin
Walking Hell21-Apr-11 7:43
Walking Hell21-Apr-11 7:43 
GeneralRe: fatal error LNK1112 Pin
Richard MacCutchan21-Apr-11 8:04
mveRichard MacCutchan21-Apr-11 8:04 
QuestionOffice converter DLLs and thread safety Pin
Mattias G20-Apr-11 23:28
Mattias G20-Apr-11 23:28 
AnswerRe: Office converter DLLs and thread safety Pin
Roger Stoltz25-Apr-11 23:28
Roger Stoltz25-Apr-11 23:28 
GeneralRe: Office converter DLLs and thread safety Pin
Mattias G27-Apr-11 2:39
Mattias G27-Apr-11 2:39 
AnswerRe: Office converter DLLs and thread safety Pin
Roger Stoltz27-Apr-11 6:05
Roger Stoltz27-Apr-11 6:05 
Mattias G wrote:
No, I wasn't hoping that calling LoadLibrary from within the thread (that later will call ForeignToRtf32) would in some magical way make the DLLs thread safe.


Ok, I just couldn't find any other explanation to what you meant by "loading a DLL within the context of a thread". I interpreted your text as, whatever you meant by it, you thought it would prevent the problems you got when trying to use multiple threads when accessing the converter DLLs.
But never mind. The only thing important is that you only need to call ::LoadLibrary() once for any DLL, subsequent calls will do nothing in practice.

I have never used the DLLs you are trying to use, nor have I found anything useful trying to google it.
So I have no idea what kind of functionality the DLLs expose, how to use them or what their function prototypes may look like.
But that may not be necessary....

Mattias G wrote:
Still getting a lot of exceptions of types 0x800401FD CO_E_OBJNOTCONNECTED and 0x8001010E RPC_E_WRONG_THREAD (though I'm not using any COM interfaces explicitly in my application).


Ok, so that means the DLLs uses COM in order to perform its ForeignToRtf32().

When you use COM from different threads you have to initialize COM for every thread that makes use of the COM library by calling e.g. ::CoInitialize() or one of its equivalents. Failure to do so may seem to work, but will cause unpredictable errors being very hard to realize that they originate from not initializing COM. In addition you have to have a message pump for every thread that creates a COM server.
Initializing COM for a thread is called setting up an "apartment" and COM interfaces are not allowed to cross apartment boundaries without being properly marshalled by using e.g. ::CoMarshalInterThreadInterfaceInStream() or the GlobalInterfaceTable(GIT). Using a COM interface from an apartment without proper marshalling will result in the error RPC_E_WRONG_THREAD.

Since you do not use any COM interfaces in your application I assume that the converter DLLs create the necessary COM servers "under the hood".
This probably means that you cannot possibly marshal any COM interface to any other thread than the one you have used to do whatever initialization needed for the converter DLLs, which should be exposed via its C-compatible interface functions.
Unless the converter DLLs expose functionality for explicitly registering different threads, it would be reasonable to assume that the converter DLLs have no means to marshal internal COM interfaces between threads originating from the client. I also think you would have tried that if such functionality was exposed by the DLLs.

My conclusion is that you can only use the converter DLLs from one thread and I would expect that thread to be forced to have a message pump. If you're up to it you can try using the converter DLLs from a worker thread without a message pump and see if it works. But I suspect there is some RPC going on between some proxy/stub pairs that will break without a message pump, causing your calls that are forwarded to any COM servers never to return.

Jig | [Dance]

"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


GeneralRe: Office converter DLLs and thread safety Pin
Mattias G29-Apr-11 0:06
Mattias G29-Apr-11 0:06 
Questionneed help in learning AES algo. Pin
gateway2320-Apr-11 23:03
gateway2320-Apr-11 23:03 
AnswerRe: need help in learning AES algo. Pin
Hans Dietrich20-Apr-11 23:33
mentorHans Dietrich20-Apr-11 23:33 
QuestionSend a Message to a Window programmatically Pin
QuickDeveloper20-Apr-11 22:37
QuickDeveloper20-Apr-11 22:37 
AnswerRe: Send a Message to a Window programmatically [modified] Pin
Mattias G20-Apr-11 23:13
Mattias G20-Apr-11 23:13 
AnswerRe: Send a Message to a Window programmatically Pin
«_Superman_»21-Apr-11 1:54
professional«_Superman_»21-Apr-11 1:54 
GeneralRe: Send a Message to a Window programmatically Pin
QuickDeveloper21-Apr-11 6:37
QuickDeveloper21-Apr-11 6:37 
GeneralRe: Send a Message to a Window programmatically Pin
Abhi Lahare21-Apr-11 8:21
Abhi Lahare21-Apr-11 8:21 
Questionhow to drag and drop image in list control Pin
rajniyadav1a20-Apr-11 21:33
rajniyadav1a20-Apr-11 21:33 
AnswerRe: how to drag and drop image in list control Pin
Hans Dietrich20-Apr-11 21:50
mentorHans Dietrich20-Apr-11 21:50 
QuestionLink Error RSA_new(); Pin
mathy20-Apr-11 19:56
mathy20-Apr-11 19:56 
AnswerRe: Link Error RSA_new(); Pin
వేంకటనారాయణ(venkatmakam)20-Apr-11 21:21
వేంకటనారాయణ(venkatmakam)20-Apr-11 21:21 
GeneralRe: Link Error RSA_new(); Pin
mathy25-Apr-11 5:10
mathy25-Apr-11 5:10 
QuestionThe application cannot get the file icon Pin
yu-jian20-Apr-11 15:30
yu-jian20-Apr-11 15:30 
AnswerRe: The application cannot get the file icon Pin
ShilpiP20-Apr-11 18:59
ShilpiP20-Apr-11 18:59 
GeneralRe: The application cannot get the file icon Pin
yu-jian26-Apr-11 15:53
yu-jian26-Apr-11 15:53 
QuestionGetVolumeInformation() on network drive Pin
hairy_hats20-Apr-11 1:34
hairy_hats20-Apr-11 1:34 

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.