Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4022004
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:25:17+00:00 2026-05-20T10:25:17+00:00

I have an object that contains a property: public Dictionary<string, List<Hotel>> CityHotels { get;

  • 0

I have an object that contains a property:

public Dictionary<string, List<Hotel>> CityHotels { get; set; }

How do I use Spring.Net to configure this property?

I tried doing this:

    <property name="CityHotels">
      <dictionary key-type="string" value-type="System.Collections.Generic.List&lt;MyNameSpace.Hotel, MyAssembly>" >
        <entry key="SYD">
            <list element-type="MyNameSpace.Hotel, MyAssembly">
            </list>
        </entry>
      </dictionary>
    </property>

but it was unsuccessful:

Error creating context ‘spring.root’: Could not load type from string value ‘System.Collections.Generic.List`2’.

What am I doing wrong?

This convoluted mess came about after I unsuccessfully tried to use Spring.Net to set a property of type ILookup, so if there is a way to do that, that would solve my problem in a cleaner way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:25:17+00:00Added an answer on May 20, 2026 at 10:25 am

    Solution for the spring config:

    <object id="HotelFinder" type="MyNameSpace.HotelFinder, MyAssembly">
      <property name="CityHotels">
        <dictionary key-type="string" value-type="System.Collections.Generic.List&lt;MyNameSpace.Hotel>, mscorlib">
          <entry key="London" value-ref="hotelsLondon" />
        </dictionary>
      </property>
    </object>
    
    <object id="hotelsLondon" type="System.Collections.Generic.List&lt;MyNameSpace.Hotel>, mscorlib">
      <constructor-arg>
          <list element-type="MyNameSpace.Hotel, MyAssembly">
             <ref object="hotelLonden1"/>
             <ref object="hotelLonden2"/>
             <ref object="hotelLonden3"/>
             <ref object="hotelLonden4"/>
           </list>
       </constructor-arg>
     </object>
    
     <object id="hotelLonden1" type="MyNameSpace.Hotel, MyAssembly" />
     <object id="hotelLonden2" type="MyNameSpace.Hotel, MyAssembly" />
     <object id="hotelLonden3" type="MyNameSpace.Hotel, MyAssembly" />
     <object id="hotelLonden4" type="MyNameSpace.Hotel, MyAssembly" />
    

    In the value-type of the dictionary you don’t need to add MyAssembly but mscorlib for System.Collections.Generic.List.

    I hope this will help you!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that contains a property-value (property bag) dictionary beside normal properties.
I have a class that contains a list of objects. What's the best way
I have an object that can build itself from an XML string, and write
I have an object that has a list of abstract 'aninamls'. i.e. var animals
I have a domain object that contains another domain object; call them A and
I have the following singleton class which contains the following property: public class Manager
Say I have a Dictionary object which contains many instances of an object called
I have a vector-like class that contains an array of objects of type T
If you have binary strings (literally String objects that contain only 1's and 0's),
I have an object that is mapped to a cookie as a serialized base-64

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.