Using a List Type Profile Property in .NET Membership

I am working on a C # web service that needs to be provided with 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 file is as follows:

<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 web service and try to access this property, it returns the following error:

System.Configuration.ConfigurationErrorsException: An attempt to load this property type resulted in the following error: Failed to load the type 'System.Collections.Generic.List <String>'. (C: \ Projects \ MyProject \ web.config line 58) ---> System.Web.HttpException: Failed to load type 'System.Collections.Generic.List <String>'.

Is there a way to use a shared collection for this purpose?

+7
c # web-services membership asp.net-membership asp.net-profiles
source share
1 answer

After more searching, I finally managed to find the answer. The solution is to use a type name corresponding to its namespace. This means that for my problem I used:

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

I also found out that you can also specify classes defined in other assemblies. To use those, you need a name that matches the assembly. For example, it 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 the Hashset of Strings.

+11
source share

All Articles