c# - 调试编辑后,Visual Studio 将有效代码误认为无效

标签 c# visual-studio resharper unity-container

我正在使用 visual studio 2013 以及使用 nuget 下载的 unity 3.5。我有如下所示的 Container 类

  public class Container
  {
    static IUnityContainer _container; //<- System IDisposable error on _container
    static ILogger _logger = GetLogger();

    //continuation here
  }

我的问题是当我执行应用程序时,调试运行良好,但是如果我在调试过程中编辑了一个与上面的类完全无关的语句,当我恢复调试时,我会得到以下奇怪的错误,_container 下面有蓝色下划线!!

enter image description here

The type 'System.IDisposable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

在此之后我将不得不停止调试并重新启动。无需触摸任何东西,错误就会消失并且可以调试回来。

我在框架程序集中查找 System.Runtime 程序集,但找不到。可用的程序集是:

System.Runtime.caching System.Runtime.DurableInstancing System.Runtime.Remoting System.Runtime.Serialization System.Runtime.Serialization.Formatters.Soap

有什么办法至少可以找到这个错误?

最佳答案

终于找到了解决办法。

%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\ 中有一个system.runtime.dll 我添加了对它的引用,它解决了问题。我不知道这样做是否正确,但至少 IDisposable 错误消失了。 我想知道为什么这个程序集没有列在标准程序集列表中。

关于c# - 调试编辑后,Visual Studio 将有效代码误认为无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30128901/

相关文章:

c# - Entity Framework 中没有显式外键的急切加载相关实体

c# - 如何使用 NuGet.Core 创建 NuGet 包?

javascript - 无法安装 Microsoft.Preview.WindowsAzure.ActiveDirectory.Authentication 目标 NETCore,版本 = v4.5

c# - 锁定可枚举可能会导致多重枚举吗?

c++ - 将右值绑定(bind)到左值引用是非标准 Microsoft C++ 扩展

.net - Resharper 不能很好地与 XAML 配合使用?

javascript - MVC字数限制

c# - getJSON 回调未触发

c# - 在 DataTriggers 中重用 ControlTemplate

visual-studio - 如何将应用程序的平台从 Windows 8.1 更改为 Windows 8?