summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/TypeLoadException.cs
diff options
context:
space:
mode:
authorJiyoung Yun <jy910.yun@samsung.com>2017-04-13 14:17:19 +0900
committerJiyoung Yun <jy910.yun@samsung.com>2017-04-13 14:17:19 +0900
commita56e30c8d33048216567753d9d3fefc2152af8ac (patch)
tree7e5d979695fc4a431740982eb1cfecc2898b23a5 /src/mscorlib/src/System/TypeLoadException.cs
parent4b11dc566a5bbfa1378d6266525c281b028abcc8 (diff)
downloadcoreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.tar.gz
coreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.tar.bz2
coreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.zip
Imported Upstream version 2.0.0.11353upstream/2.0.0.11353
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;
}
}