7

저는 역할 및 프로필 관리는 물론 인증을 제공해야하는 C# Webservice에서 작업하고 있습니다. 각 프로필에 List 유형의 속성이 있어야합니다. 의 Web.config의 프로필 섹션은 다음과 같습니다.NET에서 List 유형의 프로필 속성 사용 회원 자격

<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> 

을하지만, 나는 웹 서비스를 시작하고 다음과 같은 오류를 반환 해당 속성에 액세스하려고하면

System.Configuration.ConfigurationErrorsException를 : 시도 이 속성의 형식을로드하면 다음 오류가 발생합니다. 'System.Collections.Generic.List <String>'형식을로드 할 수 없습니다. (C : \ Projects \ MyProject \ web.config 줄 58) ---> System.Web.HttpException : 'System.Collections.Generic.List < 문자열 >'형식을로드 할 수 없습니다.

일반 컬렉션을 사용하는 방법이 있습니까?

답변

11

더 많은 검색이 끝나면 마침내 대답을 찾을 수있었습니다. 해결책은 네임 스페이스에서 규정 한 유형 이름을 사용하는 것입니다. 즉, 내 문제는 다음과 같습니다.

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

다른 어셈블리에 정의 된 클래스를 지정할 수도 있음을 알게되었습니다. 이들을 사용하려면 어셈블리 규정 이름이 필요합니다. 예를 들어, "System.Collections.Generic.HashSet`1 [System.String, mscorlib, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089], System.Core, Version = 3.5.0.0, 문화 = 중립, PublicKeyToken = b77a5c561934e089 "문자열의 Hashset합니다.

관련 문제