开发者

CannotLoadObjectTypeException in Spring.net

I'm using spring.net 1.3.1 in a asp.net 3.5 project in vs 2010. I'm not doing any kind of mvc stuff; I needed Spring to create and manipulate objects.

I've followed the documentation, added Spring.Core and Spring.Web dlls reference my web.config is like this:

   <sectionGroup name="spring">
    <section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
    <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>

  </sectionGroup> 
   <system.web>
     <httpModules>
        <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
     </httpModules>
     <!-- no spring confi in httpHandlers-->
  </system.web>
   <spring>
    <context>
      <resource uri="~/config/clients.xml" />
    </context>
  </spring>

in clients.xml

<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"> 
  <object id="CAL"  type="myrouter.clientcode.CAL, myrouter.clientcode"/>  
</objects>

in Defaults.aspx.cs

  IApplicationContext ctx = ContextRegistry.GetContext();
  CAL calobject = (CAL)ctx.GetObject("CAL");

i'm getting

[TypeLoadException: Could not load type from string value 'myrouter.clientcode.CAL, myrouter.clientcode'.] Spring.Core.TypeResolution.TypeResolver.Resolve(String typeName) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Core\TypeResolution\TypeResolver.cs:81 Spring.Core.TypeResolution.GenericTypeResolver.Resolve(String typeName) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Core\TypeResolution\GenericTypeResolver.cs:97 Spring.Core.TypeResolution.CachedTypeResolver.Resolve(String typeName) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Core\TypeResolution\CachedTypeResolver.cs:107 Spring.Core.TypeResolution.TypeResolutionUtils.ResolveType(String typeName) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Core\TypeResolution\TypeResolutionUtils.cs:106 Spring.Objects.Factory.Support.AbstractObjectDefinition.ResolveObjectType() in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectDefinition.cs:640 Spring.Objects.Factory.Support.AbstractObjectFactory.ResolveObjectType(RootObjectDefinition rod, String objectName) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectFactory.cs:1096 [CannotLoadObjectTypeException: Cannot resolve type [myrouter.clientcode.CAL, myrouter.clientcode] for object with name 'CAL' defined in file开发者_运维技巧 [D:\WORK\visual studio\Visual Studio 2010\Projects\myrouter\myrouter\config\clients.xml] line 3] Spring.Objects.Factory.Support.AbstractObjectFactory.ResolveObjectType(RootObjectDefinition rod, String objectName) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Objects\Factory\Support\AbstractObjectFactory.cs:1100 Spring.Objects.Factory.Support.DefaultListableObjectFactory.PreInstantiateSingletons() in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Objects\Factory\Support\DefaultListableObjectFactory.cs:472 Spring.Context.Support.AbstractApplicationContext.Refresh() in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Context\Support\AbstractApplicationContext.cs:1017 Spring.Context.Support.WebApplicationContext..ctor(WebApplicationContextArgs args) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Web\Context\Support\WebApplicationContext.cs:125 Spring.Context.Support.WebApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Web\Context\Support\WebApplicationContext.cs:82 _dynamic_Spring.Context.Support.WebApplicationContext..ctor(Object[] ) +242 Spring.Reflection.Dynamic.SafeConstructor.Invoke(Object[] arguments) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Reflection\Dynamic\DynamicConstructor.cs:116 Spring.Context.Support.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:563 Spring.Context.Support.ContextInstantiator.InstantiateContext() in c:_svn\spring-net\tags\spring-net-1.3.1\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:_svn\spring-net\tags\spring-net-1.3.1\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:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Web\Context\Support\WebContextHandler.cs:129 Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Context\Support\ContextHandler.cs:289 [ConfigurationErrorsException: Error creating context 'spring.root': Could not load type from string value 'myrouter.clientcode.CAL, myrouter.clientcode'.] System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) +202 System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) +1061 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) +1431 System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission) +56 System.Configuration.BaseConfigurationRecord.GetSection(String configKey) +8 System.Web.HttpContext.GetSection(String sectionName) +47 System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName) +39 System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey) +6 System.Configuration.ConfigurationManager.GetSection(String sectionName) +78 Spring.Util.ConfigurationUtils.GetSection(String sectionName) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Core\Util\ConfigurationUtils.cs:71 Spring.Context.Support.WebApplicationContext.GetContextInternal(String virtualPath) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Web\Context\Support\WebApplicationContext.cs:335 Spring.Context.Support.WebApplicationContext.GetRootContext() in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Web\Context\Support\WebApplicationContext.cs:223 Spring.Context.Support.WebSupportModule.Init(HttpApplication app) in c:_svn\spring-net\tags\spring-net-1.3.1\src\Spring\Spring.Web\Context\Support\WebSupportModule.cs:175 System.Web.HttpApplication.InitModulesCommon() +65 System.Web.HttpApplication.InitModules() +43 System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +729 System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +298 System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107 System.Web

Sorry for this long post; I wanted to be as precised as possible and give as much as information that I could. I think I'm missing something but just can't figure out what. Is the HttpHandler a must in spring.net configuration in asp.net?


Usually this issue is the result of some error in your

<object id="CAL"  type="myrouter.clientcode.CAL, myrouter.clientcode"/>  

configuration.

Check/verify the following:

  • the namespace myrouter.clientcode is really where the CAL class exists
  • the assembly that contains this type is really myrouter.clientcode
  • these namespaces and assembly names match in re: case-sensitivity as well


Never mind, i got it fixed.i used the wrong assembly info.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜