当我第一次启动我的网站时,我收到了这个错误
Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
我究竟做错了什么?
我正在使用.NET 4并从Visual Studio启动该站点.
我最近唯一改变的是将Simple Injector(通过Nuget)添加到我的项目中.
这是堆栈跟踪
[TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +180
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +192
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, …Run Code Online (Sandbox Code Playgroud) 我们有一个项目,包括使用Marshall的c ++核心库和.NET包装器(2.0和4.0).构建机器具有Windows 8.1操作系统.
C++核心和.NET 2.0包装器是使用MSVC 2005构建的,并且在具有较低Windows版本的其他机器上运行良好.
.NET 4.0包装器使用Microsoft SDK 7.1构建.库在构建机器上运行良好,但在其他机器(安装了.NET 4.0)上崩溃,并出现以下错误:
Exception: System.MissingMethodException: Method not found: 'IntPtr System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(!!0)'.
Run Code Online (Sandbox Code Playgroud)
似乎包装器是使用更高版本的.NET构建的,我不知道如何解决这个问题.据我所知,虽然它们不向后兼容,但在构建时无法强制使用特定版本的.NET 4.x.