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:38 +0545,    group: microsoft.public.platformsdk.messaging        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:38 +0545   author:   miztaken

Re: MAPIInitialize fails in Thread Environment.   
Hi miztaken,
> 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.

Make sure you are creating STA threads, i.e. apartment threaded threads.
Thread t = new Thread(...);
t.ApartmentState = ApartmentState.STA;
t.Start();

Call MAPIInitialize only once per thread at the beginning of the
thread function.

--
SvenC
date: Mon, 17 Mar 2008 10:09:19 +0100   author:   SvenC am

Google
 
Web ureader.com


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