VS2015 C#交互式:错误CS7069:对类型“对象”的引用声称它在“ System.Runtime”中定义,但找不到 [英] VS2015 C# interactive: error CS7069: Reference to type 'Object' claims it is defined in 'System.Runtime', but it could not be found
问题描述
我刚刚更新为 VS2015 Update 2 ,并开始使用 C#交互式窗口。我想在.NET 4.0目标库项目之一的静态类中使用静态方法,因此我在解决方案资源管理器中右键单击该项目,然后选择 Initialize Interactive with Project
。交互式窗口中的输出看起来像这样(为简便起见,我用 ..替换了一些完整路径):
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):错误CS7069:对类型对象的引用声称它是在 System.Runtime中定义的,但找不到它
I获取项目中的类的智能感知,但是每次尝试运行语句时,都会遇到相同的错误。我仍然可以运行以下简单的内容:
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.
推荐答案
最终为我解决的问题是输入此 中的右键。 C#交互式窗口。:
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.
这篇关于VS2015 C#交互式:错误CS7069:对类型“对象”的引用声称它在“ System.Runtime”中定义,但找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!