相关疑难解决方法(0)

无法从程序集'mscorlib加载类型'System.Runtime.CompilerServices.ExtensionAttribute'

当我第一次启动我的网站时,我收到了这个错误

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)

.net

142
推荐指数
4
解决办法
16万
查看次数

AutoFixture 无法创建 Claim(使用 .NET Framework 4.6)

我刚刚安装了VS2015,同时安装了.NET Framework 4.6,突然AutoFixture 3.30.8无法创建Claim对象。我猜新的 .NET Framework 4.6 版会导致 AutoFixture 出现一些问题。

我在 VS2013 中创建了一个包含以下代码的测试项目(针对 .NET Framework 4.5.1):

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ploeh.AutoFixture;

namespace AutoFixtureTester
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void CanCreateClaim()
        {
            var fixture = new Fixture();
            fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            var claim = fixture.Create<System.Security.Claims.Claim>(); // exception here

            Assert.IsNotNull(claim);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

错误如下:

Ploeh.AutoFixture.ObjectCreationException: AutoFixture was unable to create an instance from System.IO.Stream, most likely because it has no public constructor, is an abstract or non-public type. …
Run Code Online (Sandbox Code Playgroud)

c# autofixture visual-studio-2015 .net-4.6

5
推荐指数
1
解决办法
1076
查看次数

标签 统计

.net ×1

.net-4.6 ×1

autofixture ×1

c# ×1

visual-studio-2015 ×1