我正在使用 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 下面有蓝色下划线
!!
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/