Symptoms
The following error message appears during the processing:
EngineLoader: System.AccessViolationException: Attempted to read or write protected memory.
Cause
Using the default Engine Loader, provided with the standard C# code samples, in the EngineLoader.Dispose() method the line:
hresult = dllCanUnloadNow();
returns hresult = 1, so the FREngine.dll is not free.
This causes the following error
“System.AccessViolationException: Attempted to read or write protected memory”
, when the initializeEngine function is called in another process.
Resolution
Change the code of the EngineLoader.Dispose() in this way:
engine = null;
//int hresult = deinitializeEngine(); //delete it
// Deleting all objects before FreeLibrary call
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
int hresult = deinitializeEngine(); //put it here
hresult = dllCanUnloadNow();
Comments
0 comments
Please sign in to leave a comment.