View Full Version : Could not load type from string value
Aleksei Kachanov
09-27-2006, 01:19 PM
With such definition
<object type="~/PasswordRecovery.aspx">
<property name="ProfileDAO" ref="profDAO"/>
</object>
get such exception
Could not load type from string value '~/PasswordRecovery.aspx'.
what is wrong?
Aleksei Kachanov
09-27-2006, 01:55 PM
With such definition
<object type="~/CommonPages/UserPicker.aspx">
<property name="profileDAO" ref="profDAO"/>
<property name="institutionDAO" ref="instDAO"/>
<property name="licenseDAO" ref="licenseDAO"/>
<property name="teacherDAO" ref="teacherDAO"/>
</object>
in ~/CommonPages/web.config
such exception
The file '/SSI/CommonPages/~/CommonPages/UserPicker.aspx' does not exist.
sure ~/CommonPages/UserPicker.aspx' exists
Erich Eichinger
09-27-2006, 09:56 PM
Hi,
I'm not sure, what's happening here. But I recommend putting definitions in the web.config located next to the page and define them without path-information:
<spring>
<context>
<resource uri="config://spring/objects" />
</context>
<objects>
<object type="UserPicker.aspx">
....
</objects>
</spring>
This helps avoiding some other troubles you might run into (I did myself ;-)).
cheers,
Erich
Bruno Baia
09-27-2006, 10:45 PM
Hi Aleksei,
With such definition
<object type="~/PasswordRecovery.aspx">
<property name="ProfileDAO" ref="profDAO"/>
</object>
get such exception
Could not load type from string value '~/PasswordRecovery.aspx'.
ASP.NET pages are instantiated internally by the .NET Framework, Spring only injects dependencies on a pre-instantiated object using a named object definition. (Internally it uses IObjectFactory.ConfigureObject (http://www.springframework.net/doc/sdk/2.0/html/Spring.Core~Spring.Objects.Factory.IObjectFactory~ ConfigureObject(Object,String).html)method)
As the page cannot be instantiated by the IoC Container, you need to define it as abstract :
<object type="~/PasswordRecovery.aspx" abstract="true">
<property name="ProfileDAO" ref="profDAO"/>
</object>
-Bruno
Erich Eichinger
09-28-2006, 09:09 AM
Hi all,
ASP.NET pages are instantiated internally by the .NET Framework, Spring only injects dependencies on a pre-instantiated object using a named object definition
I know this is quite confusing - but in the case of .ASPX Pages, Aleksei's object definitions are correct. Spring *does* instantiate .aspx pages itself. Thus an .aspx definition must not be abstract.
Only .ascx instantiations are out of control for spring and must be abstract!
@Aleksei:
Are you using the latest nightly build?
cheers,
Erich
Bruno Baia
09-28-2006, 09:33 AM
I know this is quite confusing - but in the case of .ASPX Pages, Aleksei's object definitions are correct. Spring *does* instantiate .aspx pages itself. Thus an .aspx definition must not be abstract.
Only .ascx instantiations are out of control for spring and must be abstract!
You right :o I just took a look to the WebObjectDefinitionParser.
I also see that .ascx controls will be set to abstract even if you forget it in the configuration.
So I see only one problem, Aleksei updated to one of the latest nightly build but didn't applied the configuration changes (http://forum.springframework.net/showthread.php?t=697).
-Bruno
Aleksei Kachanov
10-02-2006, 07:59 AM
Are you using the latest nightly build?
Yes
Config chanhes has been applied
but give next exception
System.Web.HttpException: The file '/SSI/~/PasswordRecovery.aspx' does n
ot exist.
But if change to
<object type="PasswordRecovery.aspx">
<property name="ProfileDAO" ref="profDAO"/>
</object>
works correctly ...
Erich's fix
for
<objects>
<object type="UserPicker.aspx">
Helps, too
Does it mean now we can't define absolute with ~ as root ?
And now we should modify all to relative paths?
Aleksei Kachanov
10-02-2006, 08:04 AM
'/SSI/~/SchoolAdminArea/ExamDownloadEngine/ExamDownloadEngine.aspx' does not exist.
I have a lot of configs in sub directories
with such definitions
<objects xmlns="http://www.springframework.net">
<object type="~/SchoolAdminArea/ExamDownloadEngine/ExamDownloadEngine.aspx">
<property name="profileDAO" ref="profDAO"/>
<property name="teacherDAO" ref="teacherDAO"/>
<property name ="KeepViewStateOnServer" value="true"/>
</object>
</objects>
What I should modify or config?
Erich Eichinger
10-02-2006, 08:14 AM
Hi Aleksei,
Does it mean now we can't define absolute with ~ as root ?
And now we should modify all to relative paths?
Hopefully not. But currently we have an issue with correctly resolving resources using the "web://"-protocol (which is the default protocol within webapps) and the "~"-BasePath specifier - we are working on it.
Sorry for the inconvenience,
Erich
Aleksei Kachanov
10-02-2006, 09:03 AM
Thanks Erich,
How soon do plan resolve this issue that don't fix our configs and get the night build?
Project run production and now we can't modify config files for upgrade for new version of Spring.NET rather for developer version.
Erich Eichinger
10-02-2006, 09:16 AM
Hi Aleksei,
I'll have a look at it today. But I would also like to write some additional tests (which of course takes additional time) before committing it to cvs. I'm not sure, if I can make it until the next nightly build run.
Does it help if I post a preliminary fixed sourcefile here and you make your own build until I can commit the fix to cvs?
cheers,
Erich
Aleksei Kachanov
10-02-2006, 09:46 AM
It is not so urgently, i just update build after some moths and impact with some problems :(
And now have enough time for update
Thanks, Erich
Erich Eichinger
10-03-2006, 11:42 AM
Hi,
I just committed the fix to cvs. Please give it a try. If there are still problems, I've added a JIRA issue http://opensource.atlassian.com/projects/spring/browse/SPRNET-373
cheers,
Erich
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.