Reading a string-to-string map from an archive I have a CArchive Which contains a serialized CMapStringToString.

From my research it is my understanding that it is quite difficult to directly read a CArchive from within a C# DLL. So I decided to read it in the MFC application and feed it into the DLL interface.

At the moment I am doing the following:

m_pInterface-&gt;UpgradeDatabase();

CFile           fileNotes;
CFileException  ex;
TCHAR           szError[_MAX_PATH];
CMapStringToString mapSSBrotherNotes;

if (fileNotes.Open(_T("d:\\BrotherNotes.BIN"), CFile::modeRead, &amp;ex))
{
    TRY
    {
        CArchive ar(&amp;fileNotes, CArchive::load);
        mapSSBrotherNotes.Serialize(ar);
        ar.Close();

        POSITION sPos = mapSSBrotherNotes.GetStartPosition();
        while (sPos != NULL)
        {
            CString strName, strNotes;
            CComBSTR bstrName, bstrNotes;

            mapSSBrotherNotes.GetNextAssoc(sPos, strName, strNotes);

            bstrName = strName.AllocSysString();
            bstrNotes = strNotes.AllocSysString();

            m_pInterface-&gt;SetPublisherNotes(bstrName, bstrNotes);
        }
    }
    CATCH(CException, pEx)
    {
        pEx-&gt;GetErrorMessage(szError, _MAX_PATH);
        AfxMessageBox(szError, MB_OK | MB_ICONERROR);
    }
    END_CATCH

    fileNotes.Close();
}
else
{
    // If the file was not found, this is probably not an error
    if (ex.m_cause != CFileException::fileNotFound)
    {
        ex.GetErrorMessage(szError, _MAX_PATH);
        AfxMessageBox(szError, MB_OK | MB_ICONERROR);
    }
}
m_pInterface-&gt;SavePublisherData(&amp;iResult);


It works fine but is there a better way to read this data file from within the C# DLL?

Side question - can my use of CString / CComBSTR be simplified in my current code?
But is there a better way to read this data file from within the C# DLL?

You can write a C++/CLI wrapper. It'll compile as a .NET assembly that you can reference in your project as any other .NET dll but inside it'll be able to work with `C++ and use your current code as it is.

Visual C++ supports interoperability features that allow managed and unmanaged constructs to co-exist and interoperate within the same assembly, and even in the same file.
Mixed assemblies are capable of containing both unmanaged machine instructions and MSIL instructions. This allows them to call and be called by .NET components, while retaining compatibility with components that are entirely unmanaged. Using mixed assemblies, developers can author applications using a mixture of managed and unmanaged functionality. This makes mixed assemblies ideal for migrating existing Visual C++ applications to the .NET Platform.

Mixed (Native and Managed) Assemblies
I recommend reading

C++/CLI in Action and/or
Expert Visual C++/CLI: .NET for Visual C++ Programmers