Thanks for your reply.
I already try that before, but it my case the program structure is little different.
The problem is that the program has 2 phases:
1. Managed class creates a delegate and sends it to unmanaged class which assigns it to a function pointer member.
2. The unmanaged class listens to events from other place and when a specific event occurred then the unmanaged class should call the function in the managed class.
(From the first phase)
Maybe there is no different between cases but I still get this error.
This is almost same case. The only difference that EnumWindows calls managed callback number of times inside of method, and keeping local delegate instance is enough. In your case you need to keep delegate as class member.
I think the problem is in function prototype. What is required unmanaged prototype and managed callback prototype?
In my program I use another method for managed callback - because I didn't know about this Marshal function when started to write it. Code fragments:
Pass callbackPtr value to unmanaged class. This is simple unmanaged void* pointer, which allows to call managed class function when necessary.
// Unmanaged class calls managed class:
GCHandle h = GCHandle::FromIntPtr(IntPtr(callbackPtr)); // callbackPtr is passed from managed class
YourManagedClass^ pThis = (YourManagedClass^)h.Target;
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'D:\Dev\Test_TA.exe'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79f1c189, on thread 0x910. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
This error ocured when the function pointer in the unmanaged code call
to the function in the managed code.
In the managed code I uesd GCHandle::Aloc(this).
As looking at the web page, you can install on:
Windows, MacOS X, Linux
There is no way .NET framework is build for MacOS X, Linux.
It is pointless, to buil MuPad with .NET especaly for windows, but corp can use c++ cross-platform files, for maintaing is a lot easier, a lot cheaper, and the same techonlogy. And betwen them is very little diffrence in code. The Only big diffrence is Prebuild libraries for specific OS.