I have a 32-bit dll that I need to call from a 64-bit .NET Core Application.
My way to do this is to create a 32-bit console application, which basically looks like this:
[DllImport("x.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
static extern int x(int var);
static void Main(string[] args)
{
Console.log("I Started!");
int y = x(0);
}
And then call this from my 64bit main application with Process.Start("consoleapp.exe")
When I run consoleapp.exe, it prints "I Started!" as expected, and x.dll also performs correctly.
However, when I call consoleapp.exe from process.Start (), I get a SEHException after "I Started!" printed on the output (that is, when the DllImport part is deleted).
This is how I run the process in my 64-bit application
ProcessStartInfo p = new ProcessStartInfo("consoleapp.exe");
Process process = Process.Start(p);
process.WaitForExit();
I have already tried to impersonate the user and run the Process object as an administrator, and it does not work.
dll, x.dll consoleapp.exe, console.writeline() , x.dll.
SEHException - 0x80004005, E_FAIL "Unspecified Failure"
UPDATE: :
at Consoleapp.Consoleapp.x(int32 var)
at Consoleapp.Consoleapp.Main(String[] args)
, . External Exception, , (InnerException - null). - .
: " ".
x.dll CSIDL_COMMON_APPDATA. , , - - console.log Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData))
, . - , x.dll , , , , , .., SEHExceptions .