- You download CS-Script package from the site
- The installation instructions say to unzip the file where you want and then run
css_config.exe
to install the package. But if you run a later version of .NET, you'll likely see a message box that says this:
System.IO.FileLoadException: Could not load file or assembly 'file:///X:\Path\To\cs-script\csws.exe' or one of its dependencies. Operation is not supported (Exception from HRESULT: 0x80131515)
File name: 'file:///X:\Path\To\cs-script\csws.exe' --> System.NotSupportedException:
An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, as this load may be dangerous. If this load is not intended to sandbox the assmebly please enable the loadFromRemoteResources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information at System.Reflection.RuntimeAssembly...
What's happening? And why is it calling a local file, unzipped onto a local disk, a remote file?
What can I do?
Those files need to be unblocked.
This happened because Windows tracked the executable as emerging from a zip file that came from the internet. Borrowing a term from Perl, that zip file is "tainted" and Windows tracks the taint from the zip file to the files unzipped from it.
You may have seen the case before that a simple download-and-run executable will ask you months after its been on the system if you really want to run that executable. If you pull up the properties file, you will see the Security warning:
This file came from another computer and might be blocked to help protect this computer.
As part of that protection, the OS seems to prefer to access them like remote files. Whereas in earlier versions of .NET this was not a problem, in .NET 4, it is. CAS, or Code Access Security is more restrictive in this version, as the dialog explains.
It also says to "enable the loadFromRemoteResources switch". So after reading up on the subject, I created a
X:\Path\To\cs-script\csws.exe.config
file (because there wasn't a config file) and put into it:Which did nothing. Later I found about the
Unblock
button on the file properties dialog. But clicking that button forcsws.exe
just resulted in the dialog complaining that another executable could not be launched "remotely".So after doing some digging, I came up with the following powershell function:
And ran it like so:
After that, I was successfully able to finish the installation of cs-script.