나는 다음과 같은 간단한 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;
}
을,이 생성 된 코드입니다 실패한 경우. 코드가 누락 된 이유를 알고 있습니까?
PC에 설치된 .NET의 버전을 확인하십시오. 최신 버전 4.6에서 해당 옵션이 제거되었을 수도 있습니다. –
@Brianfromstatefarm 아니요, 4.6.1 및 4.6.2가 설치되어 있고 4.6.x에는 여전히 Ssl3 열거 형 멤버가 있습니다. – huseyint