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

空扰寡人 提交于 2019-12-19 18:58:06

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/36723359/vs2015-c-sharp-interactive-error-cs7069-reference-to-type-object-claims-it-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!