Skip to content

Interactive session errors on references to system assemblies in C# script #24

@atifaziz

Description

@atifaziz

What steps will reproduce the problem?

Create an empty LINQPad query file named Empty.linq then compile and run it as follows from a Windows Command Prompt (assuming current directory is same as where the query file is saved):

lpless  -t csx Empty.linq && Empty

The script should run without errors and emit a blank line. The compiled Empty.csx will look as follows:

#r "System.dll"
#r "Microsoft.CSharp.dll"
#r "System.Core.dll"
#r "System.Data.dll"
#r "System.Data.Entity.dll"
#r "System.Transactions.dll"
#r "System.Xml.dll"
#r "System.Xml.Linq.dll"
#r "System.Data.Linq.dll"
#r "System.Drawing.dll"
#r "System.Data.DataSetExtensions.dll"

using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Threading;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Data;
using System.Data.SqlClient;
using System.Data.Linq;
using System.Data.Linq.SqlClient;
using System.Transactions;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
System.Console.WriteLine(

);

Run a C# Interactive 2.0 (csi.exe) session and copy the content of the compiled Empty.csx above and paste it into the session.

What is the expected output? What do you see instead?

Expected the session to have the same behavior as running the script via the batch (Empty.cmd). Instead, the session emits errors for references to all system assemblies except System.dll:

Microsoft (R) Visual C# Interactive Compiler version 2.0.0.61501
Copyright (C) Microsoft Corporation. All rights reserved.

Type "#help" for more information.
> #r "System.dll"
> #r "Microsoft.CSharp.dll"
(1,1): error CS0006: Metadata file 'Microsoft.CSharp.dll' could not be found
> #r "System.Core.dll"
(1,1): error CS0006: Metadata file 'System.Core.dll' could not be found
> #r "System.Data.dll"
(1,1): error CS0006: Metadata file 'System.Data.dll' could not be found
> #r "System.Data.Entity.dll"
(1,1): error CS0006: Metadata file 'System.Data.Entity.dll' could not be found
> #r "System.Transactions.dll"
(1,1): error CS0006: Metadata file 'System.Transactions.dll' could not be found
> #r "System.Xml.dll"
(1,1): error CS0006: Metadata file 'System.Xml.dll' could not be found
> #r "System.Xml.Linq.dll"
(1,1): error CS0006: Metadata file 'System.Xml.Linq.dll' could not be found
> #r "System.Data.Linq.dll"
(1,1): error CS0006: Metadata file 'System.Data.Linq.dll' could not be found
> #r "System.Drawing.dll"
(1,1): error CS0006: Metadata file 'System.Drawing.dll' could not be found
> #r "System.Data.DataSetExtensions.dll"
(1,1): error CS0006: Metadata file 'System.Data.DataSetExtensions.dll' could not be found
>
> using System;
> using System.IO;
> using System.Text;
> using System.Text.RegularExpressions;
> using System.Diagnostics;
> using System.Threading;
> using System.Reflection;
> using System.Collections;
> using System.Collections.Generic;
> using System.Linq;
> using System.Linq.Expressions;
> using System.Data;
(1,14): error CS0234: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)
> using System.Data.SqlClient;
(1,14): error CS0234: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)
> using System.Data.Linq;
(1,14): error CS0234: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)
> using System.Data.Linq.SqlClient;
(1,14): error CS0234: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)
> using System.Transactions;
(1,14): error CS0234: The type or namespace name 'Transactions' does not exist in the namespace 'System' (are you missing an assembly reference?)
> using System.Xml;
> using System.Xml.Linq;
(1,18): error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)
> using System.Xml.XPath;
> System.Console.WriteLine(
.
. );

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions