Hosting control - oleg-shilo/cs-script.net-framework GitHub Wiki
Hosting control
When it comes to the controlling what hosting runtime is to be used for the script execution it can be tricky. The script launcher (engine) is a managed application and as such it will adhere to the CLR version it was compiled against. CS-Script allows user to specify the desired hosting options directly in the script and the script engine can dynamically relaunch the script under the desired CLR. The hosting code directive is //css_host
and it is documented here: https://www.cs-script.net/cs-script/help-legacy/hosting_control.html
While //css_host works very well in most of the cases it can impose some inconveniences (e.g. debugging). Thus you may also consider creating your own surrogate host compiled for your CPU type. It is in fact incredibly simple:
using System;
class CSScript86
{
[STAThread]
static public int Main(string[] args)
{
return AppDomain.CurrentDomain.ExecuteAssembly("<full path to cscs.exe>", args);
}
}
If you compile the code above into cscs32.exe (with 'Platform target' set to x86) it will be a 100% equivalent of the cscs.exe but running under x86 CLR.
Note: you can also find a copy of the script engine compiled for x86 (cscs32.exe) in the cs-script/lib/bin/NET 4.5
directory in the distributable package.