|
|
|
date: Wed, 27 Feb 2008 18:03:10 +0545,
group: microsoft.public.platformsdk.mapi
back
Re: MAPIInitialize fails in Thread Environment.
Hi Dmitry,
I have solved it doing like this.
#define MAPI_NO_COINIT 8
//hr=CoInitialize(lpv);
//hr=MAPIInitialize(lpv);
MAPIINIT_0 MAPIInit;
MAPIInit.ulFlags =MAPI_NO_COINIT;
MAPIInit.ulVersion = MAPI_INIT_VERSION;
hr = MAPIInitialize(&MAPIInit);
I think this is the correct convension.
Thank for the hint.
Now i want to know if i should be careful about anyother thing while running
MAPI in thread mode.
Actually i am developing project to serve multiple PST files.
Thank Once Again
"miztaken" wrote in message
news:uVS4GndeIHA.532@TK2MSFTNGP03.phx.gbl...
> Hi,
> I seem to be using older version of MAPI.
> There is no such flag as MAPI_NO_COINIT
> Do i have any other option ?
>
> Thank You
>
> "Dmitry Streblechenko" wrote in message
> news:%237UYcEZeIHA.5160@TK2MSFTNGP05.phx.gbl...
>> The error is RPC_E_CHANGED_MODE, which means .Net has already initialized
>> COM on that thread, and MAPIInitialize tries to do that again.
>> Use the MAPI_NO_COINIT flag when calling MAPIInitialize.
>>
>> Dmitry Streblechenko (MVP)
>> http://www.dimastr.com/
>> OutlookSpy - Outlook, CDO
>> and MAPI Developer Tool
>>
>> "miztaken" wrote in message
>> news:OKdDRrTeIHA.5160@TK2MSFTNGP05.phx.gbl...
>>> Hi,
>>> It now i have been creating a managed wrapper for mapi32.dll in VC++.NET
>>> 2005.
>>>
>>> Then i was consuming the managed dll in my C#.application.
>>>
>>> Everything was working fine but as i wanted to deal with multiple PST at
>>> a time so i made the Application (C#) threaded.
>>> But no soon i called the API of my managed DLL in thread,
>>> MAPIInitialize(NULL) failed and returned the error code -2147417850.
>>>
>>> I am trying to initialize mapi inside thread, for each thread.
>>>
>>> What can be wrong:-
>>> My VC++ wrapper project has following properties:
>>> Common Language Runtime Support, Old Syntax (/clr:oldSyntax)
>>> Multi-threaded Debug DLL (/MDd)
>>>
>>> where am i wrong.. please help me
>>>
>>> Thank You
>>> miztaken
>>>
>>
>>
>
>
date: Thu, 28 Feb 2008 13:21:44 +0545
author: miztaken
Re: MAPIInitialize fails in Thread Environment.
Hard to say. From my experience things work just fine unless you start
playing wiwth multiple threads.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"miztaken" wrote in message
news:eUPU$xdeIHA.1188@TK2MSFTNGP04.phx.gbl...
> Hi Dmitry,
> I have solved it doing like this.
> #define MAPI_NO_COINIT 8
>
> //hr=CoInitialize(lpv);
>
> //hr=MAPIInitialize(lpv);
>
> MAPIINIT_0 MAPIInit;
>
> MAPIInit.ulFlags =MAPI_NO_COINIT;
>
> MAPIInit.ulVersion = MAPI_INIT_VERSION;
>
> hr = MAPIInitialize(&MAPIInit);
>
> I think this is the correct convension.
>
> Thank for the hint.
>
> Now i want to know if i should be careful about anyother thing while
> running MAPI in thread mode.
> Actually i am developing project to serve multiple PST files.
>
> Thank Once Again
> "miztaken" wrote in message
> news:uVS4GndeIHA.532@TK2MSFTNGP03.phx.gbl...
>> Hi,
>> I seem to be using older version of MAPI.
>> There is no such flag as MAPI_NO_COINIT
>> Do i have any other option ?
>>
>> Thank You
>>
>> "Dmitry Streblechenko" wrote in message
>> news:%237UYcEZeIHA.5160@TK2MSFTNGP05.phx.gbl...
>>> The error is RPC_E_CHANGED_MODE, which means .Net has already
>>> initialized COM on that thread, and MAPIInitialize tries to do that
>>> again.
>>> Use the MAPI_NO_COINIT flag when calling MAPIInitialize.
>>>
>>> Dmitry Streblechenko (MVP)
>>> http://www.dimastr.com/
>>> OutlookSpy - Outlook, CDO
>>> and MAPI Developer Tool
>>>
>>> "miztaken" wrote in message
>>> news:OKdDRrTeIHA.5160@TK2MSFTNGP05.phx.gbl...
>>>> Hi,
>>>> It now i have been creating a managed wrapper for mapi32.dll in
>>>> VC++.NET 2005.
>>>>
>>>> Then i was consuming the managed dll in my C#.application.
>>>>
>>>> Everything was working fine but as i wanted to deal with multiple PST
>>>> at a time so i made the Application (C#) threaded.
>>>> But no soon i called the API of my managed DLL in thread,
>>>> MAPIInitialize(NULL) failed and returned the error code -2147417850.
>>>>
>>>> I am trying to initialize mapi inside thread, for each thread.
>>>>
>>>> What can be wrong:-
>>>> My VC++ wrapper project has following properties:
>>>> Common Language Runtime Support, Old Syntax (/clr:oldSyntax)
>>>> Multi-threaded Debug DLL (/MDd)
>>>>
>>>> where am i wrong.. please help me
>>>>
>>>> Thank You
>>>> miztaken
>>>>
>>>
>>>
>>
>>
>
>
date: Thu, 28 Feb 2008 19:13:08 -0700
author: Dmitry Streblechenko
|
|