I have a function CallerFunc( ) in a C# exe calling another function
MyFunc( ) from C++ dll. MyFunc( ) deserializes an XML request and
initializes Mapi using MapiInitialize. The first time call to MyFunc( ) is
successful and I can do all MAPI stuff successfully. However, at the second
call to MyFunc( ) from CallerFunc( ), I get an exception while deserializing
XML in MyFunc( ). Weird thing is that if I don't call MyFunc( ) from a C#
code but from a C++ test exe utility, there's never an exception. Also, if I
comment out MAPI portion of the code from MyFunc( ), there's never an
exception if called from C#. It appears that the exception is caused by
MapiInitialize in an interop environment. Any ideas?
Caller function in C#
CallerFunc( )
{
MyFunc( )
................
//some code here
................
MyFunc( ) ////Exception occurs if MyFunc is called second time
}
Called function in C++
void MyFunc( )
{
//XML deserialization ////Exception occurs here
MapiInitialize(NULL);
..........
//some code here
.........
MapiUnInitialize( );
return;
}