Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
atifaziz opened this issue Apr 6, 2017 · 2 comments
Labels

Comments

@atifaziz
Copy link
Owner

atifaziz commented Apr 6, 2017

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(
.
. );
@atifaziz atifaziz added this to the 1.1.0 milestone Apr 6, 2017
@atifaziz
Copy link
Owner Author

atifaziz commented Apr 6, 2017

Removing the .dll extension gets rid of the errors in an interactive session:

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"
> #r "Microsoft.CSharp"
> #r "System.Core"
> #r "System.Data"
> #r "System.Data.Entity"
> #r "System.Transactions"
> #r "System.Xml"
> #r "System.Xml.Linq"
> #r "System.Data.Linq"
> #r "System.Drawing"
> #r "System.Data.DataSetExtensions"
>
> 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(
.
. );

Arguably, this is a C# Interactive issue as well since it has different behavior when running a script versus when issuing the content of the script in an interactive session.

@atifaziz atifaziz added the hold label Apr 7, 2017
@atifaziz
Copy link
Owner Author

atifaziz commented Apr 7, 2017

C# Interactive issue reported to Roslyn (see dotnet/roslyn#18497). Hopefully this won't need any action on our end so putting it on hold.

@atifaziz atifaziz removed this from the 1.1.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant