Search code examples
c#.netvisual-studio-2015read-eval-print-loopc#-interactive

VS2015 C# interactive: error CS7069: Reference to type 'Object' claims it is defined in 'System.Runtime', but it could not be found


I just updated to VS2015 Update 2, and started playing around with the C# interactive window. I wanted to use a static method in a static class in one of my .NET 4.0 targeted library projects, so I right-clicked on the project in Solution Explorer, and selected Initialize Interactive with Project. The output in the interactive window looks like this (I replaced some of the full paths with '..' for brevity):

#reset
Resetting execution engine.
Loading context from 'CSharpInteractive.rsp'.
#r "..\src\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll"
#r "..\src\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll"
#r "..\src\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll"
#r "..\src\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Net.dll"
#r "..\src\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll"
#r "..\src\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.DataSetExtensions.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.CSharp.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll"
#r "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Net.Http.dll"
#r "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll"
#r "MyDll.dll"
using MyDll;
(1,7): error CS7069: Reference to type 'Object' claims it is defined in 'System.Runtime', but it could not be found

Note the nasty little line at the end, blocking my path to happiness:

(1,7): error CS7069: Reference to type 'Object' claims it is defined in 'System.Runtime', but it could not be found

I get intellisense for the classes in the project, but I get the same error any time I try to run a statement. I can still run simple things like:

> string.Format("No one knows my {0}", "suffering")
"No one knows my suffering"
>

Anyone have any ideas about why this is happening or how to fix it? I'll update this question with any [un]successful suggested fixes.


Solution

  • What ultimately fixed it for me was entering this right in the C# Interactive window.:

    #r "System.Runtime"

    If there's anyone that can provide a thorough background explanation as to why this worked, I'd love to give you the accepted answer. I just got lucky.