Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / mscorlib / system / reflection / reflectiontypeloadexception.cs
blobdf95e64a25c13b7f0cd8f06e423d23b4dbc2a88c
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 ////////////////////////////////////////////////////////////////////////////////
7 ////////////////////////////////////////////////////////////////////////////////
8 //
9 // ReflectionTypeLoadException is thrown when multiple TypeLoadExceptions may occur.
10 //
11 // <OWNER>Microsoft</OWNER>
12 // Specifically, when you call Module.GetTypes() this causes multiple class loads to occur.
13 // If there are failures, we continue to load classes and build an array of the successfully
14 // loaded classes. We also build an array of the errors that occur. Then we throw this exception
15 // which exposes both the array of classes and the array of TypeLoadExceptions.
17 //
18 //
20 namespace System.Reflection {
22 using System;
23 using System.Runtime.Serialization;
24 using System.Security.Permissions;
25 using System.Diagnostics.Contracts;
26 [Serializable]
27 [System.Runtime.InteropServices.ComVisible(true)]
28 public sealed class ReflectionTypeLoadException : SystemException, ISerializable {
29 private Type[] _classes;
30 private Exception[] _exceptions;
32 // private constructor. This is not called.
33 private ReflectionTypeLoadException()
34 : base(Environment.GetResourceString("ReflectionTypeLoad_LoadFailed")) {
35 SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
38 // private constructor. This is called from inside the runtime.
39 private ReflectionTypeLoadException(String message) : base(message) {
40 SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
43 public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions) : base(null)
45 _classes = classes;
46 _exceptions = exceptions;
47 SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
50 public ReflectionTypeLoadException(Type[] classes, Exception[] exceptions, String message) : base(message)
52 _classes = classes;
53 _exceptions = exceptions;
54 SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD);
57 internal ReflectionTypeLoadException(SerializationInfo info, StreamingContext context) : base (info, context) {
58 _classes = (Type[])(info.GetValue("Types", typeof(Type[])));
59 _exceptions = (Exception[])(info.GetValue("Exceptions", typeof(Exception[])));
62 public Type[] Types {
63 get {return _classes;}
66 public Exception[] LoaderExceptions {
67 get {return _exceptions;}
70 [System.Security.SecurityCritical] // auto-generated_required
71 public override void GetObjectData(SerializationInfo info, StreamingContext context) {
72 if (info==null) {
73 throw new ArgumentNullException("info");
75 Contract.EndContractBlock();
76 base.GetObjectData(info, context);
77 info.AddValue("Types", _classes, typeof(Type[]));
78 info.AddValue("Exceptions", _exceptions, typeof(Exception[]));