I got the following error when executing an unmanaged assembly:
Could not load file or assembly
‘file:///C:\Program
Files\Maxima-5.21.1\lib\maxima\5.21.1\binary-gcl\maxima.exe’
or one of its dependencies. The
module was expected to contain an
assembly manifest.
What should I do? Is it impossible to execute an unmanaged assembly
using AppDomain?
AppDomains are pure managed construct. Any unmanaged code running in the process is unaffected by the AppDomain boundaries and has full access to all process memory, data and code.
Unmanaged assemblies are not executed the same way managed assemblies are. The process of loading the assembly, and finding and executing the entry point for the unmanaged assembly is different than the one for managed assemblies. Hence the particular failure you get.
If you want to execute functions exported by an unmanaged dll, you should use P/Invoke, which will ensure that the assembly is loaded using the right mechanism and the proper entry point is invoked.
You can’t run code from an executable in the same process, as in your scenario above; you can only start a new process.