Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Wed, 27 Feb 2008 18:03:10 +0545,    group: microsoft.public.platformsdk.mapi        back       


MAPIInitialize fails in Thread Environment.   
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: Wed, 27 Feb 2008 18:03:10 +0545   author:   miztaken

Re: MAPIInitialize fails in Thread Environment.   
What's wrong is you're trying to use MAPI from .Net. :)

That said - error codes make much better sense in hex.

"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: Wed, 27 Feb 2008 09:09:15 -0500   author:   Stephen Griffin [MSFT]

Re: MAPIInitialize fails in Thread Environment.   
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: Wed, 27 Feb 2008 15:37:17 -0700   author:   Dmitry Streblechenko

Re: MAPIInitialize fails in Thread Environment.   
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:02:13 +0545   author:   miztaken

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

Re: MAPIInitialize fails in Thread Environment.   
Hi Dmitry,

Im trying to develop an application in VC++.Net 2003 using MAPI and EDK. Im 
able to compile the code successfully by adding the edk header files and the 
libs.
Now, I have only two linker errors:
LINK: error LNK2020: unresolved token (0A000037) std._Lockit__dtor
LINK: error LNK2020: unresolved token (0A000038) _DebugHeapTag

I have added msvcrt.lib and nochkclr.obj  as additional dependencies.
I have set /NODEFAULTLIB and also /NOENTRY in command line of Link option.

I have no idea how to solve this error.
At this point of time, i'm getting a doubt whether VC++.net supports using 
EDK APIs.

pls help me.

regards,
date: Mon, 24 Mar 2008 02:31:00 -0700   author:   kavitha

Re: MAPIInitialize fails in Thread Environment.   
I don't know, sorry, I do not use VC++.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

"kavitha"  wrote in message 
news:B1B99307-BB7B-41CD-8799-9ED9AF8706A8@microsoft.com...
> Hi Dmitry,
>
> Im trying to develop an application in VC++.Net 2003 using MAPI and EDK. 
> Im
> able to compile the code successfully by adding the edk header files and 
> the
> libs.
> Now, I have only two linker errors:
> LINK: error LNK2020: unresolved token (0A000037) std._Lockit__dtor
> LINK: error LNK2020: unresolved token (0A000038) _DebugHeapTag
>
> I have added msvcrt.lib and nochkclr.obj  as additional dependencies.
> I have set /NODEFAULTLIB and also /NOENTRY in command line of Link option.
>
> I have no idea how to solve this error.
> At this point of time, i'm getting a doubt whether VC++.net supports using
> EDK APIs.
>
> pls help me.
>
> regards,
date: Mon, 24 Mar 2008 11:22:00 -0700   author:   Dmitry Streblechenko

Re: MAPIInitialize fails in Thread Environment.   
=?Utf-8?B?a2F2aXRoYQ==?=  wrote in
news:B1B99307-BB7B-41CD-8799-9ED9AF8706A8@microsoft.com: 
> At this point of time, i'm getting a doubt whether VC++.net supports
> using EDK APIs.

 Nope, it doesn't, at least not without a lot of pain. See

http://blogs.msdn.com/jasonjoh/archive/2004/08/01/204585.aspx

 for what you should do instead.

 -- dan
date: Mon, 24 Mar 2008 12:21:57 -0700   author:   Dan Mitchell

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us