2012-09-21 43 views
3
[CannotLoadObjectTypeException: Cannot resolve type [Jtx.Service.Implement.UserManager,Jtx.Service] for object with name 'UserManager' defined in assembly [Jtx.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null], resource [Jtx.Web.Config.Controllers.xml] line 3] 
    Spring.Objects.Factory.Support.AbstractObjectFactory.ResolveObjectType(RootObjectDefinition rod, String objectName) in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectFactory.cs:1100 
    Spring.Objects.Factory.Support.DefaultListableObjectFactory.PreInstantiateSingletons() in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Objects\Factory\Support\DefaultListableObjectFactory.cs:472 
    Spring.Context.Support.AbstractApplicationContext.Refresh() in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Context\Support\AbstractApplicationContext.cs:1017 
    Spring.Context.Support.WebApplicationContext..ctor(WebApplicationContextArgs args) in c:\_prj\spring-net\trunk\src\Spring\Spring.Web\Context\Support\WebApplicationContext.cs:125 
    Spring.Context.Support.WebApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) in c:\_prj\spring-net\trunk\src\Spring\Spring.Web\Context\Support\WebApplicationContext.cs:82 
    _dynamic_Spring.Context.Support.WebApplicationContext..ctor(Object[]) in c:\_prj\spring-net\trunk\src\Spring\Spring.Web\Caching\AspNetCache.cs:126 
    Spring.Reflection.Dynamic.SafeConstructor.Invoke(Object[] arguments) in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Reflection\Dynamic\DynamicConstructor.cs:116 
    Spring.Context.Support.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:563 
    Spring.Context.Support.ContextInstantiator.InstantiateContext() in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:508 
    Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:351 
    Spring.Context.Support.WebContextHandler.InstantiateContext(IApplicationContext parent, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) in c:\_prj\spring-net\trunk\src\Spring\Spring.Web\Context\Support\WebContextHandler.cs:127 
    Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section) in c:\_prj\spring-net\trunk\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:289 

service.xml的Spring.Net,NHibernate的,ASP.NET MVC3 CannotLoadObjectTypeException

<?xml version="1.0" encoding="utf-8" ?> 
<objects xmlns="http://www.springframework.net"> 
    <object id="UserManager" type="Jtx.Service.Implement.UserManager,Jtx.Service" parent="BaseTransactionManager"> 
    <property name="CurrentRepository" ref="UserRepository"/> 
    </object> 
</objects> 

UserManager.cs

using System.Collections.Generic; 
using System.Linq; 
using Jtx.Domain.Entity; 

namespace Jtx.Service.Implement 
{ 
    public class UserInfoManager : GenericManagerBase<User>, IUserManager 
    { 
     public IList<User> LoadAllByPage(out long total, int page, int rows, string order, string sort) 
     { 
      ... 
     } 
     private string HashCode(string key) 
     { 
      ... 
     } 

     public override object Save(User entity) 
     { 
      ... 
     } 

     public User Get(string account) 
     { 
      ... 
     } 

     public User Get(string account, string password) 
     { 
      ... 
     } 

     public void Update(User entity, string password) 
     { 
      ... 
     } 
    } 

} 

enter image description here

enter image description here

的Web.config

<!--spring--> 
    <spring> 
    <parsers> 
     <parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/> 
     <parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/> 
    </parsers> 
    <context> 
     <!--Dao--> 
     <resource uri="assembly://Jtx.Dao/Jtx.Dao.Config/DaoBase.xml" /> 
     <resource uri="assembly://Jtx.Dao/Jtx.Dao.Config/Dao.xml" /> 
     <!--Service--> 
     <resource uri="assembly://Jtx.Service/Jtx.Service.Config/ServiceBase.xml" /> 
     <resource uri="assembly://Jtx.Service/Jtx.Service.Config/Service.xml" /> 
     <!--Web--> 
     <resource uri="assembly://Jtx.Web/Jtx.Web.Config/Controllers.xml" /> 
     <resource uri="config://spring/objects"/> 
    </context> 
    <objects xmlns="http://www.springframework.net"/> 
    </spring> 

我使用spring.net 1.3.2和NHibernate 3.2在VS2010一个asp.net MVC3项目。 当我调试时,只有<resource uri="assembly://Jtx.Service/Jtx.Service.Config/Service.xml" />错误。当你删除这个短语的时候,再次调试一切正常。但我检查没有发现任何错误。 与此同时,我参考CannotLoadObjectTypeException in Spring.net,也没有发现任何错误。

这个问题似乎有点混乱,我想尽可能精确地给予尽可能多的信息。

+1

+1用于删除部分配置以隔离问题。通常情况下,这将提供问题所在位置的良好提示。 – Marijn

回答

1

在service.xml中该类型是type="Jtx.Service.Implement.UserManager,Jtx.Service",但在usermanager.cs类型是UserInfoManager。你能看出其中的区别:

xml : Jtx.Service.Implement.UserManager 
code: Jtx.Service.Implement.UserInfoManager 

的XML更改为type="Jtx.Service.Implement.UserInfoManager, Jtx.Service"应该做的伎俩。

当使用spring.net和xml配置时,这些事情总是发生。 通常,(巨大)例外的第一行给出了最好的提示。 在我看到xml中的错误之前,我不得不寻找一分钟。

+0

非常感谢,因为我是一个疏忽,我改变了正常。我还发现我的班级文件名后跟一些空格。再次感谢你。 – smallTong

相关问题