未能加载程序集的错误类型 [英] Could not load type from assembly error

查看:193
本文介绍了未能加载程序集的错误类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了下面的简单的测试,在努力学习温莎城堡的流利接口:

I have written the following simple test in trying to learn Castle Windsor's Fluent Interface:

using NUnit.Framework;
using Castle.Windsor;
using System.Collections;
using Castle.MicroKernel.Registration;

namespace WindsorSample {
    public class MyComponent : IMyComponent {
        public MyComponent(int start_at) {
            this.Value = start_at;
        }
        public int Value { get; private set; }
    } 
    public interface IMyComponent {
        int Value { get; }
    }

    [TestFixture]
    public class ConcreteImplFixture {
        [Test]
        public void ResolvingConcreteImplShouldInitialiseValue() {
            IWindsorContainer container = new WindsorContainer();
            container.Register(Component.For<IMyComponent>().ImplementedBy<MyComponent>().Parameters(Parameter.ForKey("start_at").Eq("1")));
            IMyComponent resolvedComp = container.Resolve<IMyComponent>();
            Assert.AreEqual(resolvedComp.Value, 1); 
        }
    }
}

当我执行测试通过TestDriven.NET我收到以下错误:

When I execute the test through TestDriven.NET I get the following error:

System.TypeLoadException : Could not load type 'Castle.MicroKernel.Registration.IRegistration' from assembly 'Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc'.
at WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue()

当我在NUnit的GUI执行测试,我得到:

When I execute the test through the NUnit GUI I get:

WindsorSample.ConcreteImplFixture.ResolvingConcreteImplShouldInitialiseValue:
System.IO.FileNotFoundException : Could not load file or assembly 'Castle.Windsor, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The system cannot find the file specified.

如果我开大会,我引用的反射器,我可以看到它的信息是:

If I open the Assembly that I am referencing in Reflector I can see its information is:

Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc

和它确实包含 Castle.MicroKernel.Registration.IRegistration

可能是什么回事?

我要指出的二进制文件从城堡的最新版本采取虽然我有从来没有同楠,所以我也懒得再从源代码编译,只是把在bin目录中的文件。我还要指出的是,我的项目编译没有问题。

I should mention that the binaries are taken from the latest build of Castle though I have never worked with nant so I didn't bother re-compiling from source and just took the files in the bin directory. I should also point out that my project compiles with no problem.

推荐答案

在全局程序集缓存(GAC)或可能会被覆盖,你认为大会任何地方集会被加载?这通常是加载了不正确的程序集的结果,对我来说意味着我通常有一些在GAC覆盖我在斌/调试版本。

Is the assembly in the Global Assembly Cache (GAC) or any place the might be overriding the assembly that you think is being loaded? This is usually the result of an incorrect assembly being loaded, for me it means I usually have something in the GAC overriding the version I have in bin/Debug.

这篇关于未能加载程序集的错误类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆