Hi,
I’m currently working on a project where I should write a dll that allows us to extract metadata from an MXF file. This dll should be accessed by an application written in c#.
I’ve written a wrapper around mxflib in c++ to retrieve the requested information and I’ve also provided a function that can be accessed from the c# application.
To test the library I’ve written a small application in c++ that calls this function and dumps the output to stdout. This application works as expected.
When I try to do the same from within c# I receive an error: 
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I’ve traced it down ( it occurs in the ScanRIP() function) to  the line
mxffile.h line 395
Code:
template<class TP, class T> /*inline*/ TP mxflib::MXFFile__ReadObjectBase(MXFFilePtr This, PrimerPtr UsePrimer /*=NULL*/)
{
   TP Ret;
   UInt64 Location = This->Tell();
   ULPtr Key = This->ReadKey();
   // If we couldn't read the key then bug out
   if(!Key) return Ret;
   // Build the object (it may come back as an "unknown")
395:   Ret = new T(Key);
Where T is a Partition. So it happens during the contruction of a Partition Object.
My code (simplified) is:
Code:
extern "C" __declspec(dllexport) _mxfdata Getmxfdata(char* filepath)
{
   MXFFilePtr mxfFile = new MXFFile();
   mxfdata_t mxfData;
   
#ifdef COMPILED_DICT
   LoadDictionary(DictData);
#else
   LoadDictionary("dict.xml");
#endif
   
   if (!mxfFile->Open(filepath, true))
   {
      perror(filepath);
      error("Unable to open file\n");
      exit(1);
   }
   mxfFile->GetRIP();
   …
   return mxfData;
}
Has anyone else tried the same?
Does someone have an idea on what could be the culprit of my problem?
Thanks,
P.