为什么我在调用ContextRegistry.GetContext()时从Spring.NET中获得异常?

Chr*_*isF 4 c# wpf spring.net

即使解决方案如此明显,我也不应该发布这个,我将其作为提醒和其他人的有用参考点.

我的app.config文件中有以下内容:

<sectionGroup name="spring">
  <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
  <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
Run Code Online (Sandbox Code Playgroud)

其次是:

<spring>
  <context>
    <resource uri="config://spring/objects"/>
  </context>
  <objects xmlns="http://www.springframework.net">
    <object name="mediaLibrary" type="AlbumLibraryWPF.AlbumLibrary, AlbumLibraryWPF"/>
  </objects>
</spring>
Run Code Online (Sandbox Code Playgroud)

然后在我的应用程序中我得到了:

using Spring.Context;
using Spring.Context.Support;

public partial class AlbumChecker : Window
{
    private DataTable dataTable;

    private Library library;
    private Thread libraryThread;

    public AlbumChecker()
    {
        InitializeComponent();

        CreateToolTips();

        IApplicationContext ctx = ContextRegistry.GetContext();
        library = (Library)ctx.GetObject("mediaLibrary");

        // Other initialisation
    }

    // Other code
}
Run Code Online (Sandbox Code Playgroud)

它编译得非常好,但是,我在调用GetContext()时遇到异常:

Error creating context 'spring.root': Could not load type from string value
'AlbumLibraryWPF.AlbumLibrary, AlbumLibraryWPF'.
Run Code Online (Sandbox Code Playgroud)

我已经检查了Spring.NET文档并且无法看到我做错了什么 - 但我显然有错误,否则它不会引发异常!

AlbumLibraryWPF是命名空间,AlbumLibraryWPF.AlbumLibrary是我想要实例化的类的完全限定名称.我猜这就是我错了,但看不出怎么样.

Chr*_*isF 5

我觉得这么傻.

这是因为我无法将AlbumLibrary.dll复制到正确的输出目录.这意味着Spring无法找到它 - 即使在我修复了Kent突出显示的程序集名称问题之后.