How to set platform architecture for csi.exe

妖精的绣舞 提交于 2019-12-06 07:17:00

Your assembly xyz.dll is compiled to only run in a 32bit process. This might be for a good reason (such as for example loading another native dll that is available with 32bit code only). In this case, use the solution presented below. It may also be for no good reason. In this case, change the target platform of xyz.dll.


The program CSI.exe (C# Interactive Compiler) is built in a way so that it will run as a 32bit executable on a 32bit version of Windows and it will run as a 64bit executable in a 64bit version of Windows.

When running as a 64bit executable, it will not be able to load an assembly that is built to only run in a 32bit process (such as your xyz.dll).


In order to change this, you can create a version of CSI.exe that runs as a 32bit process even on a 64bit version of Windows. Follow these steps:

  1. Locate the file csi.exe, make a copy of it in the same directory and rename the copy to csi32.exe. You can find csi.exe in a path similar to "C:\Program Files (x86)\MSBuild\14.0\Bin\csi.exe"
  2. Locate the file CorFlags.exe. You can find CorFlags.exe in a path similar to "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\CorFlags.exe"
  3. Open a commandline window as administrator.
  4. Execute the following command using the correct paths for the two executable files

    C:\Path\To\CorFlags.exe /32bit+ /force C:\Path\To\csi32.exe

You can now use csi32.exe in the place of csi.exe to run scripts that require assemblies/dlls which are only available in 32bit versions.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!