MapiContact.FromVCard is failing in Mac OS X

OS: Mac 10.14
Compiler : Visual Studio for Mac 2019
Aspose.Email Ver : 21.4
Language : C#

FromVCard api is working fine with Aspose.email ver 20.11. But when i upgrade to upper version (20.12 or latest 21.4) it starts failing.

This issue is faced in Release mode only. In Debug mode it works fine.

Exception:
System.TypeLoadException: Cannot load type ‘System.String, netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’.
at . (System.Int32 , , System.Boolean& , System.Boolean ) [0x001f6] in :0
at . (System.Int32 , System.Boolean ) [0x00032] in :0
at . () [0x0002b] in :0
at . (System.Object[] , System.Type[] , System.Type[] , System.Object[] ) [0x00035] in :0
at . (System.IO.Stream , System.String , System.Object[] , System.Type[] , System.Type[] , System.Object[] ) [0x0000f] in :0
at . (System.IO.Stream , System.String , System.Object[] ) [0x00000] in :0
at . (System.IO.Stream , System.String , System.Object[] ) [0x00000] in :0
at Aspose.Email.Mapi.MapiMessageItemBase. () [0x00015] in :0
at Aspose.Email.Mapi.MapiMessageItemBase…ctor () [0x00006] in :0
at Aspose.Email.Mapi.MapiContact…ctor () [0x00000] in :0
at Aspose.Email.Mapi.MapiContact…ctor ( ) [0x00000] in :0
at Aspose.Email.Mapi.MapiContact.FromVCard (System.String filePath, System.Text.Encoding encoding) [0x00029] in :0
at MsgViewer.ViewController.ConvertVCFToCSV (System.String strFilePath, System.String strDestPath) [0x000c6] in <2905cc9dee8b449bae98219eec8b1931>:0 exception caught in VC.SVCFBEC01

Sample Code :

public void ConvertVCFToHTML(string strFilePath, string strDestPath)
{
try
{
FileStream FileStreamObj = new FileStream(strFilePath, FileMode.Open, FileAccess.Read);
StreamReader streamReaderObj = new StreamReader(FileStreamObj);
string LogPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string strTempVCFFile = string.Concat(LogPath, “/TempVCF.vcf”);

            string strRead;
            int iStart = 0;
            while ((strRead = streamReaderObj.ReadLine()) != null)
            {
                try
                {
                    if (iStart == 0)
                    {
                        int pos = strRead.ToUpper().IndexOf("BEGIN:VCARD");
                        if (pos != -1)
                        {
                            iStart = 1;
                            File.WriteAllText(strTempVCFFile, strRead, Encoding.UTF8);
                            File.AppendAllText(strTempVCFFile, "\r\n");
                            //iCurMessageCountGlobal++;
                            //this.BeginInvokeOnMainThread(new Action(() => UpdateExtractionCount()));
                            continue;

                        }
                    }
                    else
                    {
                        int pos = strRead.ToUpper().IndexOf("END:VCARD");
                        if (pos != -1)
                        {
                            File.AppendAllText(strTempVCFFile, strRead);

                            MapiContact mapiMessageItem = MapiContact.FromVCard(strTempVCFFile, Encoding.UTF8);   //strFileName
                            MemoryStream ms = new MemoryStream();
                            mapiMessageItem.Save(ms, ContactSaveFormat.Msg);
                            
                            MapiMessage mapiMessage = MapiMessage.FromStream(ms);
                            MailConversionOptions mCO = new MailConversionOptions();
                            MailMessage mailMessage = mapiMessage.ToMailMessage(mCO);
                            

                            string strHTMLFile = string.Concat(strDestPath, "/", mapiMessageItem.NameInfo.DisplayName, ".html");
                            
                            HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions();
                            htmlSaveOptions.CheckBodyContentEncoding = true;
                            HtmlFormatOptions htmlFormatOptions = HtmlFormatOptions.WriteHeader | HtmlFormatOptions.RenderVCardInfo;
                            htmlSaveOptions.RenderedContactFields = ContactFieldsSet.NameInfo | ContactFieldsSet.PersonalInfo | ContactFieldsSet.Telephones | ContactFieldsSet.Events | ContactFieldsSet.ElectronicAddresses | ContactFieldsSet.OtherFields | ContactFieldsSet.ProfessionalInfo | ContactFieldsSet.PhysicalAddresses;
                            htmlSaveOptions.HtmlFormatOptions = htmlFormatOptions;
                            mailMessage.Save(strHTMLFile, htmlSaveOptions);
                            
                            if (File.Exists(strTempVCFFile))
                            {
                                //iExportedMailCount++;
                                //iSplitFilesCount++;
                                //TotExportedCountList[iFileCount] = iExportedMailCount;
                                //this.BeginInvokeOnMainThread(new Action(() => UpdateExportStatus()));
                                File.Delete(strTempVCFFile);
                            }
                            /*if (bStopFlag == true)
                            {
                                break;
                            }
                            if (strProductType == "1")
                            {
                                if (iExportedMailCount >= 10)
                                {
                                    break;
                                }
                            }*/
                            iStart = 0;
                        }
                        else
                        {
                            File.AppendAllText(strTempVCFFile, strRead);
                            File.AppendAllText(strTempVCFFile, "\r\n");
                        }
                    }
                }
                catch (Exception e)
                {
                    string exp = string.Format("{0} exception caught", e);
                    //Log.WriteErrorLog(" " + exp + " in VC.SVCFBEC01");
                    continue;

                }
            }


        }
        catch (Exception e)
        {
            string exp = string.Format("{0} exception caught", e);
            //Log.WriteErrorLog(" " + exp + " in VC.SVCFBEC02");

        }
    }

AllContacts 2.zip (2.1 KB)

Sample vcf is attached.

@sangapankaj,
Thank you for the issue description. I’ve logged the issue in our tracking system with ID EMAILNET-40217. Our development team will investigate this case. I will inform you about any progress.

@sangapankaj,
Our development team investigated the issue.

  1. Based on the type of exception, it looks like the error is not related to our code, but rather to your application environment. Please clear Nuget’s cache.
  2. If the issue persists, please share how Aspose.Email was used (via Nuget or a reference). It would be great if you send us a simple test project.
  3. Also please clarify the Aspose.Email version - this code does not compile with 20.11 because some properties (i. e. HtmlFormatOptions.RenderVCardInfo) are not present in version 20.11.