Using a profile property of type List in .NET Membership

asp.net-membership, asp.net-profiles, c#, membership, web-services

Solution

After more searching I finally managed to find the answer. The solution is to use the type name qualified by its namespace. This means that for my issue I used:

<add name="Websites" type="System.Collections.Generic.List`1[System.String]" serializeAs="Binary"/>

I also found out that it is also possible to specify classes defined in other assemblies. To use those you need the assembly-qualified name. For example, that would be "System.Collections.Generic.HashSet`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" for a Hashset of Strings.

Problem

I'm working on a C# Webservice that needs to provide authentication as well as roles and profile management. I need each profile to have a property of type List. The profile section in the web.config looks like this: ``` <profile defaultProvider="MyProfileProvider" enabled="true"> <providers> <remove name="MyProfileProvider"/> <add connectionStringName="MySqlServer" applicationName="MyApp" name="MyProfileProvider" type="System.Web.Profile.SqlProfileProvider" /> </providers> <properties> <add name="Websites" type="System.Collections.Generic.List&lt;String&gt;" serializeAs="Binary"/> </properties> </profile> ``` However, when I start the webservice and try to access that property it returns the following error: System.Configuration.ConfigurationErrorsException: Attempting to load this property's type resulted in the following error: Could not load type 'System.Collections.Generic.List<String>'. (C:\Projects\MyProject\web.config line 58) ---> System.Web.HttpException: Could not load type 'System.Collections.Generic.List<String>'. Is there a way to use a generic collection for this purpose?

Original source