summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/TypeLoadException.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/TypeLoadException.cs')
-rw-r--r--src/mscorlib/src/System/TypeLoadException.cs106
1 files changed, 58 insertions, 48 deletions
diff --git a/src/mscorlib/src/System/TypeLoadException.cs b/src/mscorlib/src/System/TypeLoadException.cs
index 7bc3a1bcce..85e1da5920 100644
--- a/src/mscorlib/src/System/TypeLoadException.cs
+++ b/src/mscorlib/src/System/TypeLoadException.cs
@@ -10,56 +10,63 @@
**
**
=============================================================================*/
-namespace System {
-
- using System;
- using System.Globalization;
- using System.Runtime.Remoting;
- using System.Runtime.Serialization;
- using System.Runtime.InteropServices;
- using System.Runtime.CompilerServices;
- using System.Runtime.Versioning;
- using System.Security;
- using System.Diagnostics.Contracts;
- [Serializable]
- public class TypeLoadException : SystemException, ISerializable {
+using System;
+using System.Globalization;
+using System.Runtime.Remoting;
+using System.Runtime.Serialization;
+using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
+using System.Runtime.Versioning;
+using System.Security;
+using System.Diagnostics.Contracts;
- public TypeLoadException()
- : base(Environment.GetResourceString("Arg_TypeLoadException")) {
- SetErrorCode(__HResults.COR_E_TYPELOAD);
+namespace System
+{
+ [Serializable]
+ public class TypeLoadException : SystemException, ISerializable
+ {
+ public TypeLoadException()
+ : base(SR.Arg_TypeLoadException)
+ {
+ HResult = __HResults.COR_E_TYPELOAD;
}
-
- public TypeLoadException(String message)
- : base(message) {
- SetErrorCode(__HResults.COR_E_TYPELOAD);
+
+ public TypeLoadException(String message)
+ : base(message)
+ {
+ HResult = __HResults.COR_E_TYPELOAD;
}
-
- public TypeLoadException(String message, Exception inner)
- : base(message, inner) {
- SetErrorCode(__HResults.COR_E_TYPELOAD);
+
+ public TypeLoadException(String message, Exception inner)
+ : base(message, inner)
+ {
+ HResult = __HResults.COR_E_TYPELOAD;
}
-
+
public override String Message
{
- get {
+ get
+ {
SetMessageField();
return _message;
}
}
-
+
private void SetMessageField()
{
- if (_message == null) {
+ if (_message == null)
+ {
if ((ClassName == null) &&
(ResourceId == 0))
- _message = Environment.GetResourceString("Arg_TypeLoadException");
+ _message = SR.Arg_TypeLoadException;
- else {
+ else
+ {
if (AssemblyName == null)
- AssemblyName = Environment.GetResourceString("IO_UnknownFileName");
+ AssemblyName = SR.IO_UnknownFileName;
if (ClassName == null)
- ClassName = Environment.GetResourceString("IO_UnknownFileName");
+ ClassName = SR.IO_UnknownFileName;
String format = null;
GetTypeLoadExceptionMessage(ResourceId, JitHelpers.GetStringHandleOnStack(ref format));
@@ -70,50 +77,53 @@ namespace System {
public String TypeName
{
- get {
+ get
+ {
if (ClassName == null)
return String.Empty;
return ClassName;
}
}
-
+
// This is called from inside the EE.
private TypeLoadException(String className,
String assemblyName,
String messageArg,
- int resourceId)
+ int resourceId)
: base(null)
{
- SetErrorCode(__HResults.COR_E_TYPELOAD);
- ClassName = className;
+ HResult = __HResults.COR_E_TYPELOAD;
+ ClassName = className;
AssemblyName = assemblyName;
MessageArg = messageArg;
ResourceId = resourceId;
// Set the _message field eagerly; debuggers look at this field to
// display error info. They don't call the Message property.
- SetMessageField();
+ SetMessageField();
}
- protected TypeLoadException(SerializationInfo info, StreamingContext context) : base(info, context) {
+ protected TypeLoadException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
if (info == null)
throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
- ClassName = info.GetString("TypeLoadClassName");
+ ClassName = info.GetString("TypeLoadClassName");
AssemblyName = info.GetString("TypeLoadAssemblyName");
MessageArg = info.GetString("TypeLoadMessageArg");
ResourceId = info.GetInt32("TypeLoadResourceID");
}
-
+
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void GetTypeLoadExceptionMessage(int resourceId, StringHandleOnStack retString);
-
+
//We can rely on the serialization mechanism on Exception to handle most of our needs, but
//we need to add a few fields of our own.
- public override void GetObjectData(SerializationInfo info, StreamingContext context) {
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
if (info == null)
throw new ArgumentNullException(nameof(info));
Contract.EndContractBlock();
@@ -124,13 +134,13 @@ namespace System {
info.AddValue("TypeLoadMessageArg", MessageArg, typeof(String));
info.AddValue("TypeLoadResourceID", ResourceId);
}
-
+
// If ClassName != null, GetMessage will construct on the fly using it
// and ResourceId (mscorrc.dll). This allows customization of the
// class name format depending on the language environment.
- private String ClassName;
- private String AssemblyName;
- private String MessageArg;
- internal int ResourceId;
+ private String ClassName;
+ private String AssemblyName;
+ private String MessageArg;
+ internal int ResourceId;
}
}