Why am I having an error trying to locally install cs-script?

1
  • 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?

.net
windows
code-access-security
cs-script
asked on Stack Overflow Nov 13, 2014 by Axeman • edited Nov 13, 2014 by Axeman

2 Answers

1

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: Properties Dialog

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:

<configuration>
   <runtime>
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>

Which did nothing. Later I found about the Unblock button on the file properties dialog. But clicking that button for csws.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:

function Unblock-All { Get-ChildItem @args -Recurse | Unblock-File }

And ran it like so:

Unblock-All X:\Path\To\cs-script

After that, I was successfully able to finish the installation of cs-script.

answered on Stack Overflow Nov 13, 2014 by Axeman • edited Nov 13, 2014 by Axeman
0

The solution to this problem is to create the configuration file on the installer, i.e. X:\Path\To\cs-script\css_config.exe.config containing:

<configuration>
   <runtime>
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>
answered on Stack Overflow May 24, 2016 by Phate01

User contributions licensed under CC BY-SA 3.0