Can I run scripts using LegacyV2RuntimeActivationPolicy?
I have a DLL (Microsoft.SqlServer.BatchParser) that I need to reference in my scriptcs file.
The following DLL can only be listed if useLegacyV2RuntimeActivationPolicy is included in the app.config file.
For example, this is a console application:
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
var batchParser = new ManagedBatchParser.Parser();
}
}
}
will only compile if I have included useLegacyV2RuntimeActivationPolicy in app.config like so:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
</configuration>
But to do the same in the CSX file:
#r "Microsoft.Sqlserver.BatchParser"
var batchParser = new ManagedBatchParser.Parser();
will fail because I don't know how to specify this attribute. I get the infamous error as soon as I try to run the scriptcs file:
Additional Information: The mixed mode assembly is built against runtime version 'v2.0.50727' and cannot be loaded into the 4.0 runtime without additional configuration information.
So my main question is, how can I tell scripts to start compiling the CSX file using the useLegacyV2RuntimeActivationPolicy attribute?
source to share