System.MissingMethodException的Int32统环境。 get_CurrentManagedThreadId() [英] System.MissingMethodException Int32 System.Environment. get_CurrentManagedThreadId()
问题描述
什么会导致以下异常?
System.MissingMethodException Int32 System.Environment.get_CurrentManagedThreadId()
这个方法调用似乎是由C#编译器产生的方法产生的的IEnumerable<>
This method call seems to be generated by C# compiler for methods yielding IEnumerable<>
.
.NET框架4.0版x86安装和二进制编译为V4.0的任何CPU。
.NET Framework v4.0 x86 is installed and the binary is compiled for v4.0 Any CPU.
推荐答案
CurrentManagedThreadId
是一个.NET 4.5的财产,所以你需要4.5运行code 。
请参见迭代器块,缺少方法和.NET 4.5 怎么会出现这个问题的分析。
CurrentManagedThreadId
is a .NET 4.5 property, so you will need 4.5 to run the code.
See Iterator blocks, missing methods, and .NET 4.5 for an analysis of how this problem might occur.
简而言之:
如果你建立你的应用程序使用.NET 4.5安装在系统上(针对.NET 4.0),它将采用4.5为基础编制的,因为.NET 4.0框架总是覆盖由.NET 4.5。
If you build your application (targeted at .NET 4.0) on a system with .NET 4.5 installed, it will use 4.5 as basis for the compilation, because the .NET 4.0 Framework is always overwritten by .NET 4.5.
如果您的应用程序,然后还使用收益率回报
,它就会失败仅4.0安装,因为这条语句的执行采用了全新的属性时编为4.5框架具有系统
If your application then also uses yield return
, it will fail on systems having only 4.0 installed because the implementation of this statement uses a new property when compiled for the 4.5 Framework.
要解决这个问题,请确保您的编译器系统具有4.0的引用程序集。
To solve it, make sure your compiler system has the 4.0 reference assemblies.
这篇关于System.MissingMethodException的Int32统环境。 get_CurrentManagedThreadId()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!