For over two years I have been developing a web front end for ScummVM as a 'challenge project'.
There is a .NET entrypoint which talks via C++/CLI to ScummVM, written in C++.
The C++ code consists of
C++/CLI Ref classes compiling to .NET Framework Assembly
Unmanaged C++ classes with C++ CLI Support Enabled compiling to lib
Ordinary C++ written by me for interfacing with ScummVM
The ScummVM code base
In order to access some of latest .NET features I updated the .NET portion of the code to .NET Core.
The C++ codebase portion was not touched. I left the C++/CLI portion .NET Framework as .NET Core doesn't support C++ CLI lib files.
I ran into an issue in the C++ code I cannot explain. Most of the code functions just I would expect it to, however in a few places
I am now getting memory corruption issues in a handful of places in the C++ code (not any place were CLI is used).
I am now in the situation that when I call my C++ code from a .NET Framework entry point it works, but when I call the same code from a .NET Core Entry point it fails.
I know that MS supports the calling of .NET Framework assemblies from .NET Core, as long as there are no deprecated APIs.
I have yet to find any documentation on whether there is support for calling C++/CLI .NET Framework from .NET core. I am certainly successfully calling the C++ code,
I am just getting the strange behaviour noted above.
I can't show every part of the the code that breaks, as that would be too overwhelming. However, here is an example of some code that fails when the entry point is .NET Core:
UnmanagedSaveWrapper.h
nativeScummVmWrapperSaveMemStream.h:
1 2 3 4 5
|
...
typedef std::function<Common::String(Common::String input, std::vector<byte>)> AddToCache;
NativeScummVmWrapperSaveMemStream(... AddToCache addToCache ...);
...
| |
UnmanagedWrapper.cpp:
1 2 3 4 5 6 7 8
|
OutSaveFile *ScummWeb::ScummService::Saving::Cache::UnmanagedSaveManagerWrapper::openForSaving(bool compress) {
return new Common::OutSaveFile(new NativeScummVmWrapperSaveMemStream(... [this](std::vector<byte> saveData)
{
//Content of the lamda has no effect
},
}));
}
| |
When the lamda is called or returns (I am not sure which). A breakpoint is triggered in XMemory: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\include\xmemory deallocate.
Respectfully please don't talk to me about usefulness. This is a learning project for me.