2017-01-25 4 views
5

나는 다음과 같은 간단한 XML 직렬화 유형이 있습니다누락 SecurityProtocolType.Ssl3 열거 값

[XmlType] 
public class TestType 
{ 
    public System.Net.SecurityProtocolType ProtocolType { get; set; } 
} 

var instanceToSerialize = new TestType { ProtocolType = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 }; 

내가 내 컴퓨터 및 여러 컴퓨터에 잘이 개체의 인스턴스를 직렬화 할 수 있습니다. 내가 일하는 경우 실패에 대한 sgen.exe 생성 된 코드를 비교 한

System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Instance validation error: '4080' is not a valid value for System.Net.SecurityProtocolType. 
at System.Xml.Serialization.XmlCustomFormatter.FromEnum(Int64 val, String[] vals, Int64[] ids, String typeName) 
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterTestType.Write1_SecurityProtocolType(SecurityProtocolType v) 
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterTestType.Write3_TestType(String n, String ns, TestType o, Boolean isNullable, Boolean needType) 
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterTestType.Write4_TestType(Object o) 

:하지만 테스트 한 컴퓨터 중 하나에, 나는 다음과 같은 예외를 얻고있다. 작업의 경우에 내가 생성이 코드가 있습니다

string Write1_SecurityProtocolType(global::System.Net.SecurityProtocolType v) { 
    string s = null; 
    switch (v) { 
     case global::[email protected]: s = @"Tls"; break; 
     case global::[email protected]: s = @"Tls11"; break; 
     case global::[email protected]: s = @"Tls12"; break; 
     default: s = FromEnum(((System.Int64)v), new string[] {@"Tls", 
      @"Tls11", 
      @"Tls12"}, new System.Int64[] {(long)global::[email protected], 
      (long)global::[email protected], 
      (long)global::[email protected]}, @"System.Net.SecurityProtocolType"); break; 
    } 
    return s; 
} 

당신은 Ssl3 열거 형 멤버에 대한 코드가 생성되지 않는다는 것을 알 수 있습니다 실패한 코드에 반면

string Write1_SecurityProtocolType(global::System.Net.SecurityProtocolType v) { 
    string s = null; 
    switch (v) { 
     case global::[email protected]: s = @"Ssl3"; break; 
     case global::[email protected]: s = @"Tls"; break; 
     case global::[email protected]: s = @"Tls11"; break; 
     case global::[email protected]: s = @"Tls12"; break; 
     default: s = FromEnum(((System.Int64)v), new string[] {@"Ssl3", 
      @"Tls", 
      @"Tls11", 
      @"Tls12"}, new System.Int64[] {(long)global::[email protected], 
      (long)global::[email protected], 
      (long)global::[email protected], 
      (long)global::[email protected]}, @"System.Net.SecurityProtocolType"); break; 
    } 
    return s; 
} 

을,이 생성 된 코드입니다 실패한 경우. 코드가 누락 된 이유를 알고 있습니까?

+0

PC에 설치된 .NET의 버전을 확인하십시오. 최신 버전 4.6에서 해당 옵션이 제거되었을 수도 있습니다. –

+0

@Brianfromstatefarm 아니요, 4.6.1 및 4.6.2가 설치되어 있고 4.6.x에는 여전히 Ssl3 열거 형 멤버가 있습니다. – huseyint

답변

3

일반 진단은 SGen.exe가 잘못된 참조 어셈블리와 함께 실행되었음을 나타냅니다. /reference 명령 줄 옵션은 사용하지 않으면 c : \ windows \ microsoft.net의 항목으로 되돌아갑니다.

신발이 맞으면 SecurityProtocolType 열거 형이 매우 변덕 스럽습니다. .NET 4.0에서 4.5로 변경되어 Tls11 및 Tls12 열거 형 멤버가 추가되었습니다. Q + A를 많이 사용하면 4.0을 목표로하는 프로젝트에서도 사용할 수 있습니다. SSLv3에 큰 문제가 있으며, beyond repair이 손상되었습니다. 따라서 Microsoft는 프로그래머가 사용하지 못하도록 막으려하고 있습니다. 다시 볼 수있는 내용은 the .NETCore declaration입니다. [Obsolete] 특성은 SGen.exe가주의를 기울이는 특성입니다.

참조 어셈블리의 어떤 풍미가 사용될 수 있었는지는 분명하지 않습니다. SslProtocols.Ssl3에는 .NETCore의 [Obsolete] 특성이 있지만 SecurityProtocolType 열거 형 멤버는 does not입니다. 따라서 SGen.exe는 실수로 .NETCore 참조 어셈블리를 사용하여 설명하지 않습니다. Mono 나 Xamarin과 같은 것은 쉽게 설명하지 못합니다. Silverlight 또는 PCL 참조 어셈블리는 적어도 내 컴퓨터에는 해당되지 않습니다. 우키 베타 버전은 언제나 가능합니다.

SGen.exe에 비정상적인 /reference 인수를 사용하는 알려진 이유가없는 한 해당 컴퓨터에서 .NET Framework를 다시 설치하는 것이 가장 좋습니다. 그리고 Ssl3의 사용을 중단하면, 그것은 정말로 쓸모가 없습니다.