views:

445

answers:

2

I'm trying to use a generic list as a property of the users profile. I'll admit this is probably just making my life harder than it needs to be but I don't want to change the programming model just because the data store struggles.

I have this in my web.config

  </providers>
  <properties>
   .....
   <add name="AListProperty" type="System.Collections.Generic.List`1[[System.Int32]]"/>
   <add name="AnotherListProperty" type="System.Collections.Generic.List`1[[MyNamespace.Web.UI.MyReallySimpleClass]]">
      </properties>
 </profile>

The first property, "AListProperty" works fine. The second one throws a variety of exceptions depending on how I delcare it in the web.config. MyReallySimpleClass is public, serializable and consists of 2 public fields (at present)

So, my questions are 1. Does anyone know where the format for declaring these types in the web.config is documented. 2. What I'm doing wrong? It looks fine, I can't see any semantic difference between the two declarations.

Thanks

+2  A: 

It would help if you could also give some details about the exception types and message you are experiencing. Otherwise my guess would be that you may need to qualify MyNamespace.Web.UI.MyReallySimpleClass with the assembly where the type lives, as in MyNamespace.Web.UI.MyReallySimpleClass, MyAssembly. The assembly qualification is not be needed unless the type lives in mscorlib, as System.Int32 does, under App_Code or in one of the assemblies listed in the system.web/compilation/assemblies section of the configuration.

  1. Does anyone know where the format for declaring these types in the web.config is documented.

See Specifying Fully Qualified Type Names in MSDN.

Atif Aziz
I didn't put a vote for your answer because you statement about the assembly qualification not being needed is confusing. You say "not needed unless..."? but system.int32 works without an assembly qualification. My class lives in the output assembly of the project, but still needed assembly qualif
Frustrating Developments
I thought I clarified that point. If the assembly qualification is missing then mscorlib is always checked. Since Int32 lives in mscorlib, it didn't need you specify the assembly explicitly.
Atif Aziz
+2  A: 

Try to specify the assembly of YourReallySimpleClass:

...type="System.Collections.Generic.List`1[[MyNamespace.Web.UI.MyReallySimpleClass, MyAssemblyName]]"
gius
after I added the assembly qualication, then corrected my spelling it stated working. thanks
Frustrating Developments