{
internal Utils() { }
public static System.Array CopyArray(System.Array arySrc, System.Array aryDest) { throw null; }
+ public static string GetResourceString(string ResourceKey, params string[] Args) { throw null; }
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public sealed partial class Versioned
Return CByte(DoubleType.Parse(Value))
Catch e As FormatException
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromStringTo, Left(Value, 32), "Byte"), e) 'UNSIGNED: make these strings constants
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromStringTo, Left(Value, 32), "Byte"), e) 'UNSIGNED: make these strings constants
End Try
End Function
End Select
ThrowInvalidCast:
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Byte"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Byte"))
End Function
End If
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Char()"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Char()"))
End Function
End Select
End If
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Char"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Char"))
End Function
End Class
ElseIf Result = ConversionClass.Ambiguous Then
Throw New InvalidCastException(
- GetResourceString(
+ SR.Format(
SR.AmbiguousCast2,
VBFriendlyName(SourceType),
VBFriendlyName(TargetType)))
End If
Throw New InvalidCastException(
- GetResourceString(
+ SR.Format(
SR.InvalidCast_FromTo,
VBFriendlyName(SourceType),
VBFriendlyName(TargetType)))
Return ParsedDate
Else
'Truncate the string to 32 characters for the message
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromStringTo, Left(Value, 32), "Date"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromStringTo, Left(Value, 32), "Date"))
End If
End Function
End If
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Date"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Date"))
End Function
Friend Shared Function TryParse(ByVal Value As String, ByRef Result As System.DateTime) As Boolean
Friend Const DISP_E_NOTACOLLECTION As Integer = &H80020011I
Friend Shared Function VbMakeIllegalForException() As System.Exception
- Return VbMakeExceptionEx(vbErrors.IllegalFor, GetResourceString(SR.ID92)) ' 92 - IllegaFor
+ Return VbMakeExceptionEx(vbErrors.IllegalFor, SR.Format(SR.ID92)) ' 92 - IllegaFor
End Function
Friend Shared Function VbMakeObjNotSetException() As System.Exception
- Return VbMakeExceptionEx(vbErrors.ObjNotSet, GetResourceString(SR.ID91)) ' 91 - ObjNotSet
+ Return VbMakeExceptionEx(vbErrors.ObjNotSet, SR.Format(SR.ID91)) ' 91 - ObjNotSet
End Function
Friend Shared Function VbMakeException(ByVal hr As Integer) As System.Exception
Case vbErrors.None
- Case vbErrors.ReturnWOGoSub, _
- vbErrors.ResumeWOErr, _
- vbErrors.CantUseNull, _
+ Case vbErrors.ReturnWOGoSub,
+ vbErrors.ResumeWOErr,
+ vbErrors.CantUseNull,
vbErrors.DoesntImplementICollection
Return New InvalidOperationException(Description)
- Case vbErrors.IllegalFuncCall, _
- vbErrors.NamedParamNotFound, _
- vbErrors.NamedArgsNotSupported, _
+ Case vbErrors.IllegalFuncCall,
+ vbErrors.NamedParamNotFound,
+ vbErrors.NamedArgsNotSupported,
vbErrors.ParameterNotOptional
Return New ArgumentException(Description)
Case vbErrors.EndOfFile
Return New IO.EndOfStreamException(Description)
- Case vbErrors.IOError, _
- vbErrors.BadFileNameOrNumber, _
- vbErrors.BadFileMode, _
- vbErrors.FileAlreadyOpen, _
- vbErrors.FileAlreadyExists, _
- vbErrors.BadRecordLen, _
- vbErrors.DiskFull, _
- vbErrors.BadRecordNum, _
- vbErrors.TooManyFiles, _
- vbErrors.DevUnavailable, _
- vbErrors.PermissionDenied, _
- vbErrors.DiskNotReady, _
- vbErrors.DifferentDrive, _
+ Case vbErrors.IOError,
+ vbErrors.BadFileNameOrNumber,
+ vbErrors.BadFileMode,
+ vbErrors.FileAlreadyOpen,
+ vbErrors.FileAlreadyExists,
+ vbErrors.BadRecordLen,
+ vbErrors.DiskFull,
+ vbErrors.BadRecordNum,
+ vbErrors.TooManyFiles,
+ vbErrors.DevUnavailable,
+ vbErrors.PermissionDenied,
+ vbErrors.DiskNotReady,
+ vbErrors.DifferentDrive,
vbErrors.PathFileAccess
Return New IO.IOException(Description)
- Case vbErrors.PathNotFound, _
+ Case vbErrors.PathNotFound,
vbErrors.OLEFileNotFound
Return New IO.FileNotFoundException(Description)
Case vbErrors.PropertyNotFound
Return New MissingFieldException(Description)
- Case vbErrors.CantCreateObject, _
+ Case vbErrors.CantCreateObject,
vbErrors.ServerNotFound
Return New Exception(Description)
VBDefinedError = False
Return New Exception(Description)
-
+
End Function
''' <summary>
Friend Shared Function GetArgumentExceptionWithArgName(ByVal ArgumentName As String,
ByVal ResourceID As String, ByVal ParamArray PlaceHolders() As String) As ArgumentException
- Return New ArgumentException(GetResourceString(ResourceID, PlaceHolders), ArgumentName)
+ Return New ArgumentException(SR.Format(ResourceID, PlaceHolders), ArgumentName)
End Function
''' <summary>
''' <returns>A new instance of ArgumentNullException.</returns>
Friend Shared Function GetArgumentNullException(ByVal ArgumentName As String) As ArgumentNullException
- Return New ArgumentNullException(ArgumentName, GetResourceString(SR.General_ArgumentNullException))
+ Return New ArgumentNullException(ArgumentName, SR.General_ArgumentNullException)
End Function
''' <summary>
Friend Shared Function GetArgumentNullException(ByVal ArgumentName As String,
ByVal ResourceID As String, ByVal ParamArray PlaceHolders() As String) As ArgumentNullException
- Return New ArgumentNullException(ArgumentName, GetResourceString(ResourceID, PlaceHolders))
+ Return New ArgumentNullException(ArgumentName, SR.Format(ResourceID, PlaceHolders))
End Function
''' <summary>
Friend Shared Function GetDirectoryNotFoundException(
ByVal ResourceID As String, ByVal ParamArray PlaceHolders() As String) As IO.DirectoryNotFoundException
- Return New IO.DirectoryNotFoundException(GetResourceString(ResourceID, PlaceHolders))
+ Return New IO.DirectoryNotFoundException(SR.Format(ResourceID, PlaceHolders))
End Function
''' <summary>
Friend Shared Function GetFileNotFoundException(ByVal FileName As String,
ByVal ResourceID As String, ByVal ParamArray PlaceHolders() As String) As IO.FileNotFoundException
- Return New IO.FileNotFoundException(GetResourceString(ResourceID, PlaceHolders), FileName)
+ Return New IO.FileNotFoundException(SR.Format(ResourceID, PlaceHolders), FileName)
End Function
''' <summary>
Friend Shared Function GetInvalidOperationException(
ByVal ResourceID As String, ByVal ParamArray PlaceHolders() As String) As InvalidOperationException
- Return New InvalidOperationException(GetResourceString(ResourceID, PlaceHolders))
+ Return New InvalidOperationException(SR.Format(ResourceID, PlaceHolders))
End Function
''' <summary>
''' <returns>A new instance of IO.IOException.</returns>
Friend Shared Function GetIOException(ByVal ResourceID As String, ByVal ParamArray PlaceHolders() As String) As IO.IOException
- Return New IO.IOException(GetResourceString(ResourceID, PlaceHolders))
+ Return New IO.IOException(SR.Format(ResourceID, PlaceHolders))
End Function
''' <summary>
Friend Shared Function GetWin32Exception(
ByVal ResourceID As String, ByVal ParamArray PlaceHolders() As String) As ComponentModel.Win32Exception
- Return New ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), GetResourceString(ResourceID, PlaceHolders))
+ Return New ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), SR.Format(ResourceID, PlaceHolders))
End Function
End Class
' default constructor
Public Sub New()
- MyBase.New(GetResourceString(SR.InternalError_VisualBasicRuntime))
+ MyBase.New(SR.InternalError_VisualBasicRuntime)
End Sub
End Class
oAssemblyData = ProjectData.GetProjectData().GetAssemblyData(assem)
If oAssemblyData.m_DirFiles Is Nothing Then
- Throw New ArgumentException(GetResourceString(SR.DIR_IllegalCall))
+ Throw New ArgumentException(SR.DIR_IllegalCall)
End If
If oAssemblyData.m_DirNextFileIndex > oAssemblyData.m_DirFiles.GetUpperBound(0) Then
Return CInt(DoubleType.Parse(Value))
Catch e As FormatException
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromStringTo, Left(Value, 32), "Integer"), e)
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromStringTo, Left(Value, 32), "Integer"), e)
End Try
End Function
' Fall through to error
End Select
ThrowInvalidCast:
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Integer"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Integer"))
End Function
Private Shared Function DecimalToInteger(ByVal ValueInterface As IConvertible) As Integer
oTmp = Nothing
End Try
If oTmp Is Nothing Then
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
Else
Try
Return LateIndexGet(oTmp, args, paramnames)
End Try
End If
Else
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
End If
Catch ex As TargetInvocationException
If RValueBase AndAlso objType.IsValueType Then
'note that objType is passed byref to InternalLateSet and that it
'should be valid by the time we get to this point
- Throw New Exception(GetResourceString(SR.RValueBaseForValueType, VBFriendlyName(objType, o), VBFriendlyName(objType, o)))
+ Throw New Exception(SR.Format(SR.RValueBaseForValueType, VBFriendlyName(objType, o), VBFriendlyName(objType, o)))
End If
Catch ex As System.MissingMemberException When OptimisticSet = True
'A missing member exception means it has no Set member. Silently handle the exception.
Dim NewValue As Object
If fi.IsInitOnly Then
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_ReadOnlyField2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_ReadOnlyField2, name, VBFriendlyName(objType, o)))
End If
If (args Is Nothing OrElse args.Length = 0) Then
'Everything must be shadowed
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
ElseIf args.Length = 1 Then
NewValue = args(0)
End Try
If oTmp Is Nothing Then
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
Else
Try
LateIndexSet(oTmp, args, paramnames)
End Try
End If
Else
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
End If
Catch ex As TargetInvocationException
ElseIf TypeOf ex.InnerException Is TargetParameterCountException Then
If (flags And BindingFlags.PutRefDispProperty) <> 0 Then
'Set was being called
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberSetNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberSetNotFoundOnType2, name, VBFriendlyName(objType, o)))
Else
'Let was being called
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberLetNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberLetNotFoundOnType2, name, VBFriendlyName(objType, o)))
End If
Else
Throw ex.InnerException
If objType.BaseType.FullName = "System.__ComObject" Then
Return
End If
- Throw New InvalidOperationException(GetResourceString(SR.LateboundCallToInheritedComClass))
+ Throw New InvalidOperationException(SR.LateboundCallToInheritedComClass)
End Sub
'Named arguments are not allowed as indexers
If paramnames IsNot Nothing AndAlso paramnames.Length <> 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidNamedArgs))
+ Throw New ArgumentException(SR.Argument_InvalidNamedArgs)
End If
Dim ArgCount As Integer
'Catch the missing method here, Invoke below will throw an ArgumentException
If members Is Nothing Or iNext = 0 Then
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType, o)))
End If
match = New MethodBase(iNext - 1) {}
For i = 0 To iNext - 1
End If
Catch ex As Exception When IsMissingMemberException(ex)
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType, o)))
Catch ex As TargetInvocationException
Throw ex.InnerException
LateIndexSet(o, args, paramnames)
If RValueBase AndAlso o.GetType().IsValueType Then
- Throw New Exception(GetResourceString(SR.RValueBaseForValueType, o.GetType().Name, o.GetType().Name))
+ Throw New Exception(SR.Format(SR.RValueBaseForValueType, o.GetType().Name, o.GetType().Name))
End If
Catch ex As System.MissingMemberException When OptimisticSet = True
'A missing member exception means it has no Set member. Silently handle the exception.
'Named arguments are not allowed as indexers
If paramnames IsNot Nothing AndAlso paramnames.Length <> 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidNamedArgs))
+ Throw New ArgumentException(SR.Argument_InvalidNamedArgs)
End If
Dim ArgCount As Integer
'Catch the missing method here, Invoke below will throw an ArgumentException
If members Is Nothing Or iNext = 0 Then
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType, o)))
End If
match = New MethodBase(iNext - 1) {}
Catch ex As Exception When IsMissingMemberException(ex)
'Override the message so that we're consistent with above Throw
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType, o)))
Catch ex As TargetInvocationException
Throw ex.InnerException
mi = GetMembersByName(objIReflect, name, flags)
If (mi Is Nothing) OrElse (mi.Length = 0) Then
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
End If
If MemberIsField(mi) Then
'This expression is not a procedure, but occurs as the target of a procedure call.
- Throw New ArgumentException(GetResourceString(SR.ExpressionNotProcedure, name, VBFriendlyName(objType, o)))
+ Throw New ArgumentException(SR.Format(SR.ExpressionNotProcedure, name, VBFriendlyName(objType, o)))
End If
'Try a FastCall
If member.MemberType = MemberTypes.Property Then
member = CType(member, PropertyInfo).GetGetMethod()
If member Is Nothing Then
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
End If
End If
'Some exceptions can occur that need to be mapped to MissingMemberException
Catch ex As Exception When IsMissingMemberException(ex)
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType, o)))
Catch ex As TargetInvocationException
Throw ex.InnerException
If Not IsStatic Then
'Reference to non-shared member '|1' requires an object reference.
Throw New NullReferenceException(
- GetResourceString(SR.NullReference_InstanceReqToAccessMember1, MemberToString(Member)))
+ SR.Format(SR.NullReference_InstanceReqToAccessMember1, MemberToString(Member)))
End If
End If
End Sub
Options)
If RangePatternError Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Pattern"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Pattern"))
End If
If RangeMismatch Then
Options)
If AsteriskPatternError Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Pattern"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Pattern"))
End If
Return Not AsteriskMismatch
Catch e As FormatException
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromStringTo, Left(Value, 32), "Long"), e)
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromStringTo, Left(Value, 32), "Long"), e)
End Try
End Function
' Fall through to error
End Select
ThrowInvalidCast:
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Long"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Long"))
End Function
Private Shared Function DecimalToLong(ByVal ValueInterface As IConvertible) As Long
failure = ResolutionFailure.InvalidArgument
If reportErrors Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidNamedArgs))
+ Throw New ArgumentException(SR.Argument_InvalidNamedArgs)
End If
Return Nothing
If members(0).MemberType = MemberTypes.Field Then
If typeArguments.Length > 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
Dim fieldValue As Object = baseReference.GetFieldValue(DirectCast(members(0), FieldInfo))
If argumentNames.Length > arguments.Length OrElse
(copyBack IsNot Nothing AndAlso copyBack.Length <> arguments.Length) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
Dim failure As OverloadResolution.ResolutionFailure
'For backwards compatibility, throw a missing member exception if the intermediate result is Nothing.
If result Is Nothing Then
Throw New MissingMemberException(
- GetResourceString(
+ SR.Format(
SR.IntermediateLateBoundNothingResult1,
targetProcedure.ToString,
baseReference.VBFriendlyName))
'This is an array lookup and assignment o(a) = v.
If argumentNames.Length > 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidNamedArgs))
+ Throw New ArgumentException(SR.Argument_InvalidNamedArgs)
End If
baseReference.SetArrayValue(arguments)
End If
If argumentNames.Length > arguments.Length Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
If arguments.Length < 1 Then
'We're binding to a Set, we must have at least the Value argument.
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
Dim methodName As String = ""
If rValueBase AndAlso baseReference.IsValueType Then
Throw New Exception(
- GetResourceString(
+ SR.Format(
SR.RValueBaseForValueType,
baseReference.VBFriendlyName,
baseReference.VBFriendlyName))
If members(0).MemberType = MemberTypes.Field Then
If TypeArguments.Length > 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
If Arguments.Length = 1 Then
If RValueBase AndAlso baseReference.IsValueType Then
Throw New Exception(
- GetResourceString(
+ SR.Format(
SR.RValueBaseForValueType,
baseReference.VBFriendlyName,
baseReference.VBFriendlyName))
invocationFlags = BindingFlagsSetProperty
If ArgumentNames.Length > Arguments.Length Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
Dim failure As OverloadResolution.ResolutionFailure
If failure = OverloadResolution.ResolutionFailure.None Then
If RValueBase AndAlso baseReference.IsValueType Then
Throw New Exception(
- GetResourceString(
+ SR.Format(
SR.RValueBaseForValueType,
baseReference.VBFriendlyName,
baseReference.VBFriendlyName))
'For backwards compatibility, throw a missing member exception if the intermediate result is Nothing.
If result Is Nothing Then
Throw New MissingMemberException(
- GetResourceString(
+ SR.Format(
SR.IntermediateLateBoundNothingResult1,
targetProcedure.ToString,
baseReference.VBFriendlyName))
failure = ResolutionFailure.InvalidArgument
If reportErrors Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
Return Nothing
If reportErrors Then
'If we're binding to a Set, we must have at least the Value argument.
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
Return Nothing
If HasFlag(flags, BindingFlagsSetProperty) Then
Debug.Assert(targetProcedure.AsProperty.GetSetMethod Is Nothing, "expected error condition")
Return New MissingMemberException(
- GetResourceString(SR.NoSetProperty1, targetProcedure.AsProperty.Name))
+ SR.Format(SR.NoSetProperty1, targetProcedure.AsProperty.Name))
Else
Debug.Assert(targetProcedure.AsProperty.GetGetMethod Is Nothing, "expected error condition")
Return New MissingMemberException(
- GetResourceString(SR.NoGetProperty1, targetProcedure.AsProperty.Name))
+ SR.Format(SR.NoGetProperty1, targetProcedure.AsProperty.Name))
End If
End Function
If reportErrors Then
'This expression is not a procedure, but occurs as the target of a procedure call.
Throw New ArgumentException(
- GetResourceString(SR.ExpressionNotProcedure, methodName, baseReference.VBFriendlyName))
+ SR.Format(SR.ExpressionNotProcedure, methodName, baseReference.VBFriendlyName))
End If
Return Nothing
End If
If reportErrors Then
Throw New InvalidCastException(
- GetResourceString(SR.PropertySetMissingArgument1, methodName))
+ SR.Format(SR.PropertySetMissingArgument1, methodName))
End If
Return Nothing
errorMessage &= vbCrLf & " " & errorString
Next
- errorMessage = GetResourceString(SR.MatchArgumentFailure2, resolutionResult.ToString, errorMessage)
+ errorMessage = SR.Format(SR.MatchArgumentFailure2, resolutionResult.ToString, errorMessage)
'We are missing a member which can match the arguments, so throw a missing member exception.
'The InvalidCastException is thrown only for back compat. It would
'be nice if the latebinder had its own set of exceptions to throw.
If reportErrors Then
'Methods can't be targets of assignments.
Throw New MissingMemberException(
- GetResourceString(SR.MethodAssignment1, resolutionResult.AsMethod.Name))
+ SR.Format(SR.MethodAssignment1, resolutionResult.AsMethod.Name))
End If
Return Nothing
End If
errorMessage &= vbCrLf & " " & errorString
Next
- errorMessage = GetResourceString(SR.MatchArgumentFailure2, resolutionResult.ToString, errorMessage)
+ errorMessage = SR.Format(SR.MatchArgumentFailure2, resolutionResult.ToString, errorMessage)
'The selected member can't handle the type of the Value argument, so this is an argument exception.
'The InvalidCastException is thrown only for back compat. It would
'be nice if the latebinder had its own set of exceptions to throw.
Public Shared Sub CheckForSyncLockOnValueType(ByVal Expression As Object)
If Expression IsNot Nothing AndAlso Expression.GetType.IsValueType() Then
Throw New ArgumentException(
- GetResourceString(SR.SyncLockRequiresReferenceType1, VBFriendlyName(Expression.GetType)))
+ SR.Format(SR.SyncLockRequiresReferenceType1, VBFriendlyName(Expression.GetType)))
End If
End Sub
Catch ex As OutOfMemoryException
Throw ex
Catch
- Throw New ArgumentException(GetResourceString(SR.ForLoop_ConvertToType3, elementName, VBFriendlyName(sourceType), VBFriendlyName(targetType)))
+ Throw New ArgumentException(SR.Format(SR.ForLoop_ConvertToType3, elementName, VBFriendlyName(sourceType), VBFriendlyName(targetType)))
End Try
End Function
Dim operatorMethod As Method = Operators.GetCallableUserDefinedOperator(op, forLoopArgument, forLoopArgument)
If operatorMethod Is Nothing Then
- Throw New ArgumentException(GetResourceString(
+ Throw New ArgumentException(SR.Format(
SR.ForLoop_OperatorRequired2,
VBFriendlyNameOfType(forLoopArgumentType, fullName:=True),
Symbols.OperatorNames(op)))
parameters(0).ParameterType IsNot forLoopArgumentType OrElse
parameters(1).ParameterType IsNot forLoopArgumentType OrElse
operatorInfo.ReturnType IsNot forLoopArgumentType Then
- Throw New ArgumentException(GetResourceString(
+ Throw New ArgumentException(SR.Format(
SR.ForLoop_UnacceptableOperator2,
operatorMethod.ToString,
VBFriendlyNameOfType(forLoopArgumentType, fullName:=True)))
If parameters.Length <> 2 OrElse
parameters(0).ParameterType IsNot forLoopArgumentType OrElse
parameters(1).ParameterType IsNot forLoopArgumentType Then
- Throw New ArgumentException(GetResourceString(
+ Throw New ArgumentException(SR.Format(
SR.ForLoop_UnacceptableRelOperator2,
operatorMethod.ToString,
VBFriendlyNameOfType(forLoopArgumentType, fullName:=True)))
Dim loopFor As ForLoopControl
If (Start Is Nothing) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidNullValue1, "Start"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidNullValue1, "Start"))
ElseIf (Limit Is Nothing) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidNullValue1, "Limit"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidNullValue1, "Limit"))
ElseIf (StepValue Is Nothing) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidNullValue1, "Step"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidNullValue1, "Step"))
End If
Dim startType As Type = Start.GetType()
Dim widestType As Type = GetWidestType(stepType, startType, limitType)
If widestType Is Nothing Then
- Throw New ArgumentException(GetResourceString(SR.ForLoop_CommonType3, VBFriendlyName(startType), VBFriendlyName(limitType), VBFriendlyName(StepValue)))
+ Throw New ArgumentException(SR.Format(SR.ForLoop_CommonType3, VBFriendlyName(startType), VBFriendlyName(limitType), VBFriendlyName(StepValue)))
End If
loopFor = New ForLoopControl
End If
If Counter Is Nothing Then
- Throw New NullReferenceException(GetResourceString(SR.Argument_InvalidNullValue1, "Counter"))
+ Throw New NullReferenceException(SR.Format(SR.Argument_InvalidNullValue1, "Counter"))
End If
loopFor = CType(LoopObj, ForLoopControl)
If counterTypeCode <> loopFor._widestTypeCode OrElse counterTypeCode = TypeCode.String Then
If counterTypeCode = TypeCode.Object Then
- Throw New ArgumentException(GetResourceString(SR.ForLoop_CommonType2, VBFriendlyName(MapTypeCodeToType(counterTypeCode)), VBFriendlyName(loopFor._widestType)))
+ Throw New ArgumentException(SR.Format(SR.ForLoop_CommonType2, VBFriendlyName(MapTypeCodeToType(counterTypeCode)), VBFriendlyName(loopFor._widestType)))
Else
Dim widestType As Type = GetWidestType(MapTypeCodeToType(counterTypeCode), loopFor._widestType)
Dim widestTypeCode As TypeCode = GetTypeCode(widestType)
End If
Catch ex As InvalidCastException
- Throw New ArgumentException(GetResourceString(SR.Argument_IComparable2, "loop control variable", VBFriendlyName(loopFor._counter)))
+ Throw New ArgumentException(SR.Format(SR.Argument_IComparable2, "loop control variable", VBFriendlyName(loopFor._counter)))
End Try
Else
If loopFor._positiveStep Then
End Select
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(obj), VBFriendlyName(TypeFromTypeCode(toType))))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(obj), VBFriendlyName(TypeFromTypeCode(toType))))
End Function
If (ObjString IsNot Nothing) AndAlso (toType Is GetType(Char())) Then
Return CharArrayType.FromString(ObjString)
Else
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(fromType), VBFriendlyName(toType)))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(fromType), VBFriendlyName(toType)))
End If
End If
Else
End Function
Private Shared Function GetNoValidOperatorException(ByVal Operand As Object) As Exception
- Return New InvalidCastException(GetResourceString(SR.NoValidOperator_OneOperand, VBFriendlyName(Operand)))
+ Return New InvalidCastException(SR.Format(SR.NoValidOperator_OneOperand, VBFriendlyName(Operand)))
End Function
Private Shared Function GetNoValidOperatorException(ByVal Left As Object, ByVal Right As Object) As Exception
If LeftString IsNot Nothing Then
Substitution1 =
- GetResourceString(SR.NoValidOperator_StringType1, Strings.Left(LeftString, MAX_INSERTION_SIZE))
+ SR.Format(SR.NoValidOperator_StringType1, Strings.Left(LeftString, MAX_INSERTION_SIZE))
Else
- Substitution1 = GetResourceString(SR.NoValidOperator_NonStringType1, VBFriendlyName(Left))
+ Substitution1 = SR.Format(SR.NoValidOperator_NonStringType1, VBFriendlyName(Left))
End If
End If
If RightString IsNot Nothing Then
Substitution2 =
- GetResourceString(SR.NoValidOperator_StringType1, Strings.Left(RightString, MAX_INSERTION_SIZE))
+ SR.Format(SR.NoValidOperator_StringType1, Strings.Left(RightString, MAX_INSERTION_SIZE))
Else
- Substitution2 = GetResourceString(SR.NoValidOperator_NonStringType1, VBFriendlyName(Right))
+ Substitution2 = SR.Format(SR.NoValidOperator_NonStringType1, VBFriendlyName(Right))
End If
End If
- Return New InvalidCastException(GetResourceString(SR.NoValidOperator_TwoOperands, Substitution1, Substitution2))
+ Return New InvalidCastException(SR.Format(SR.NoValidOperator_TwoOperands, Substitution1, Substitution2))
End Function
'**
errorMessage &= vbCrLf & " " & errorString
Next
- errorMessage = GetResourceString(SR.MatchArgumentFailure2, operatorMethod.ToString, errorMessage)
+ errorMessage = SR.Format(SR.MatchArgumentFailure2, operatorMethod.ToString, errorMessage)
'We are missing a member which can match the arguments, so throw a missing member exception.
Throw New InvalidCastException(errorMessage)
End If
End Function
Private Shared Function GetNoValidOperatorException(ByVal op As UserDefinedOperator, ByVal operand As Object) As Exception
- Return New InvalidCastException(GetResourceString(SR.UnaryOperand2, OperatorNames(op), VBFriendlyName(operand)))
+ Return New InvalidCastException(SR.Format(SR.UnaryOperand2, OperatorNames(op), VBFriendlyName(operand)))
End Function
Private Shared Function GetNoValidOperatorException(ByVal op As UserDefinedOperator, ByVal left As Object, ByVal right As Object) As Exception
If leftString IsNot Nothing Then
substitution1 =
- GetResourceString(SR.NoValidOperator_StringType1, Strings.Left(leftString, maxInsertionSize))
+ SR.Format(SR.NoValidOperator_StringType1, Strings.Left(leftString, maxInsertionSize))
Else
- substitution1 = GetResourceString(SR.NoValidOperator_NonStringType1, VBFriendlyName(left))
+ substitution1 = SR.Format(SR.NoValidOperator_NonStringType1, VBFriendlyName(left))
End If
End If
If rightString IsNot Nothing Then
substitution2 =
- GetResourceString(SR.NoValidOperator_StringType1, Strings.Left(rightString, maxInsertionSize))
+ SR.Format(SR.NoValidOperator_StringType1, Strings.Left(rightString, maxInsertionSize))
Else
- substitution2 = GetResourceString(SR.NoValidOperator_NonStringType1, VBFriendlyName(right))
+ substitution2 = SR.Format(SR.NoValidOperator_NonStringType1, VBFriendlyName(right))
End If
End If
- Return New InvalidCastException(GetResourceString(SR.BinaryOperands3, OperatorNames(op), substitution1, substitution2))
+ Return New InvalidCastException(SR.Format(SR.BinaryOperands3, OperatorNames(op), substitution1, substitution2))
End Function
#Region " Comparison Operators = <> < <= > >= "
Debug.Assert(errors IsNot Nothing, "expected error table")
errors.Add(
- GetResourceString(
+ SR.Format(
resourceID,
substitution1,
VBFriendlyName(substitution2),
Debug.Assert(errors IsNot Nothing, "expected error table")
errors.Add(
- GetResourceString(
+ SR.Format(
resourceID,
substitution1,
substitution2.ToString))
Debug.Assert(errors IsNot Nothing, "expected error table")
errors.Add(
- GetResourceString(
+ SR.Format(
resourceID,
substitution1))
End Sub
Private Shared Sub ReportError(ByVal errors As List(Of String), ByVal resourceID As String)
Debug.Assert(errors IsNot Nothing, "expected error table")
- errors.Add(
- GetResourceString(resourceID))
+ errors.Add(resourceID)
End Sub
Private Delegate Function ArgumentDetector(
Debug.Assert(candidateReportCount > 0, "expected at least one candidate")
- Dim message As String = GetResourceString(errorID, overloadedProcedureName, errorMessage.ToString)
+ Dim message As String = SR.Format(errorID, overloadedProcedureName, errorMessage.ToString)
If candidateReportCount = 1 Then
'ParamArrays may cause only one candidate to get reported. In this case, reporting an
'ambiguity is misleading.
ElseIf rejectedForTypeArgumentCount > 0 Then
errorID = SR.NoTypeArgumentCountOverloadCandidates1
End If
- Throw New MissingMemberException(GetResourceString(errorID, methodName))
+ Throw New MissingMemberException(SR.Format(errorID, methodName))
End If
Return Nothing
End If
If assem Is Utils.VBRuntimeAssembly OrElse assem Is m_CachedMSCoreLibAssembly Then
'Must have been from a latebound call to our own apis (potentially through context of mscorlib)
'This must not be allowed, as it would cause files to be shared across assemblies
- Throw New Security.SecurityException(GetResourceString(SR.Security_LateBoundCallsNotPermitted))
+ Throw New Security.SecurityException(SR.Security_LateBoundCallsNotPermitted)
End If
Dim AssemData As AssemblyData = CType(m_AssemblyData.Item(assem), AssemblyData)
Return CShort(DoubleType.Parse(Value))
Catch e As FormatException
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromStringTo, Left(Value, 32), "Short"), e)
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromStringTo, Left(Value, 32), "Short"), e)
End Try
End Function
' Fall through to error
End Select
ThrowInvalidCast:
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Short"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Short"))
End Function
Return CSng(Result)
Catch e As FormatException
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromStringTo, Left(Value, 32), "Single"), e)
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromStringTo, Left(Value, 32), "Single"), e)
End Try
End Function
End Select
ThrowInvalidCast:
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Single"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "Single"))
End Function
Private Shared Function DecimalToSingle(ByVal ValueInterface As IConvertible) As Single
End If
End If
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(Value), "String"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(Value), "String"))
End Function
If SourceEndIndex = 0 Then
Return False
Else
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Pattern"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Pattern"))
End If
Else
Return (PatternIndex = PatternEndIndex) AndAlso (SourceIndex = SourceEndIndex)
If SourceEndIndex = 0 Then
Return False
Else
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Pattern"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Pattern"))
End If
Else
Return (PatternIndex = PatternEndIndex) AndAlso (SourceIndex = SourceEndIndex)
StartPosition -= 1
If StartPosition < 0 OrElse StartPosition >= DestLength Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Start"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))
End If
If MaxInsertLength < 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Length"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Length"))
End If
' first, limit the length of the source string
If result.Length = 0 Then
If reportErrors Then
Throw New MissingMemberException(
- GetResourceString(SR.MissingMember_NoDefaultMemberFound1, Me.VBFriendlyName))
+ SR.Format(SR.MissingMember_NoDefaultMemberFound1, Me.VBFriendlyName))
End If
Return result
If result.Length = 0 Then
If reportErrors Then
Throw New MissingMemberException(
- GetResourceString(SR.MissingMember_MemberNotFoundOnType2, memberName, Me.VBFriendlyName))
+ SR.Format(SR.MissingMember_MemberNotFoundOnType2, memberName, Me.VBFriendlyName))
End If
Return result
If _instance Is Nothing AndAlso Not IsShared(field) Then
'Reference to non-shared member '|1' requires an object reference.
Throw New NullReferenceException(
- GetResourceString(SR.NullReference_InstanceReqToAccessMember1, FieldToString(field)))
+ SR.Format(SR.NullReference_InstanceReqToAccessMember1, FieldToString(field)))
End If
'
'BEGIN: SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY
Friend Sub SetFieldValue(ByVal field As FieldInfo, ByVal value As Object)
If field.IsInitOnly Then
Throw New MissingMemberException(
- GetResourceString(SR.MissingMember_ReadOnlyField2, field.Name, Me.VBFriendlyName))
+ SR.Format(SR.MissingMember_ReadOnlyField2, field.Name, Me.VBFriendlyName))
End If
If _instance Is Nothing AndAlso Not IsShared(field) Then
'Reference to non-shared member '|1' requires an object reference.
Throw New NullReferenceException(
- GetResourceString(SR.NullReference_InstanceReqToAccessMember1, FieldToString(field)))
+ SR.Format(SR.NullReference_InstanceReqToAccessMember1, FieldToString(field)))
End If
'
'BEGIN: SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY
If _instance Is Nothing AndAlso Not IsShared(callTarget) Then
'Reference to non-shared member '|1' requires an object reference.
Throw New NullReferenceException(
- GetResourceString(SR.NullReference_InstanceReqToAccessMember1, targetProcedure.ToString))
+ SR.Format(SR.NullReference_InstanceReqToAccessMember1, targetProcedure.ToString))
End If
'
'BEGIN: SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY
Friend Const OptionCompareTextFlags As CompareOptions = (CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreKanaType)
+ Private Const ResourceMsgDefault As String = "Message text unavailable. Resource file 'Microsoft.VisualBasic resources' not found."
+ Private Const VBDefaultErrorID As String = "ID95"
Friend Shared m_achIntlSpace() As Char = {chSpace, chIntlSpace}
Private Shared ReadOnly s_voidType As Type = System.Type.GetType("System.Void")
Private Shared s_VBRuntimeAssembly As System.Reflection.Assembly
- '*****************************************************************************
- ';GetResourceString
- '
- 'Summary: Retrieves a resource string and formats it by replacing placeholders
- ' with params. For example if the unformatted string is
- ' "Hello, {0}" then GetString("StringID", "World") will return "Hello, World"
- ' This one is exposed because I have to be able to get at localized error
- ' strings from the MY template
- ' Param: ID - Identifier for the string to be retrieved
- ' Param: Args - An array of params used to replace placeholders.
- 'Returns: The resource string if found or an error message string
- '*****************************************************************************
+ Private Shared Function GetFallbackMessage(ByVal name As String, ByVal ParamArray args() As Object) As String
+ 'last-ditch effort; just give back name
+ Return name
+ End Function
+
Friend Shared Function GetResourceString(ByVal ResourceId As vbErrors) As String
- Dim id as String = "ID" & CStr(ResourceId)
+ Dim id As String = "ID" & CStr(ResourceId)
Return SR.GetResourceString(id, id)
End Function
- Friend Shared Function GetResourceString(ByVal resourceKey As String, ByVal ParamArray args() As String) As String
- Return SR.Format(resourceKey, args)
+ <System.ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Never)>
+ Friend Shared Function GetResourceString(ByVal ResourceKey As String) As String
+
+ Dim s As String = Nothing
+
+ Try
+ s = SR.GetResourceString(ResourceKey)
+ ' this may be unknown error, so try getting default message
+ If s Is Nothing Then
+ s = SR.GetResourceString(VBDefaultErrorID)
+ End If
+
+ 'if we have found nothing, get a fallback message.
+ If s Is Nothing Then
+ s = GetFallbackMessage(ResourceKey)
+ End If
+ Catch ex As StackOverflowException
+ Throw ex
+ Catch ex As OutOfMemoryException
+ Throw ex
+ Catch ex As System.Threading.ThreadAbortException
+ Throw ex
+ Catch
+ s = ResourceMsgDefault
+ End Try
+
+ Return s
+ End Function
+
+ ''' <summary>
+ ''' Retrieves a resource string and formats it by replacing placeholders with parameters.
+ ''' </summary>
+ ''' <param name="ResourceKey">The resource string identifier</param>
+ ''' <param name="Args">An array of parameters used to replace placeholders</param>
+ ''' <returns>The resource string if found or an error message string</returns>
+ Public Shared Function GetResourceString(ByVal ResourceKey As String, ByVal ParamArray Args() As String) As String
+
+ System.Diagnostics.Debug.Assert(Not ResourceKey = "", "ResourceKey is missing")
+ System.Diagnostics.Debug.Assert(Not Args Is Nothing, "No Args")
+
+ Dim UnformattedString As String = Nothing
+ Dim FormattedString As String = Nothing
+ Try
+ 'Get unformatted string which may have place holders ie "Hello, {0}. How is {1}?"
+ UnformattedString = GetResourceString(ResourceKey)
+
+ 'Replace placeholders with items from the passed in array
+ FormattedString = String.Format(System.Threading.Thread.CurrentThread.CurrentCulture, UnformattedString, Args)
+
+ 'Rethrow hosting exceptions
+ Catch ex As StackOverflowException
+ Throw ex
+ Catch ex As OutOfMemoryException
+ Throw ex
+ Catch ex As System.Threading.ThreadAbortException
+ Throw ex
+
+ Catch ex As Exception
+ System.Diagnostics.Debug.Fail("Unable to get and format string for ResourceKey: " & ResourceKey)
+ Finally
+ System.Diagnostics.Debug.Assert(Not UnformattedString = "", "Unable to get string for ResourceKey: " & ResourceKey)
+ System.Diagnostics.Debug.Assert(Not FormattedString = "", "Unable to format string for ResourceKey: " & ResourceKey)
+ End Try
+
+ 'Return the string if we have one otherwise return a default error message
+ If Not FormattedString = "" Then
+ Return FormattedString
+ Else
+ Return UnformattedString 'will contain an error string from the attempt to load via the GetResourceString() overload we call internally
+ End If
End Function
Friend Shared Function StdFormat(ByVal s As String) As String
If UnsafeNativeMethods.SetLocalTime(systime) = 0 Then
If Marshal.GetLastWin32Error() = ERROR_INVALID_PARAMETER Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
Else
- Throw New SecurityException(GetResourceString(SR.SetLocalTimeFailure))
+ Throw New SecurityException(SR.SetLocalTimeFailure)
End If
End If
#Else
If UnsafeNativeMethods.SetLocalTime(systime) = 0 Then
If Marshal.GetLastWin32Error() = ERROR_INVALID_PARAMETER Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
Else
- Throw New SecurityException(GetResourceString(SR.SetLocalDateFailure))
+ Throw New SecurityException(SR.SetLocalDateFailure)
End If
End If
#Else
' the implementation of Lock in base class VB6RandomFile does not handle m_lRecordLen=-1
Friend Overloads Overrides Sub Lock(ByVal lStart As Long, ByVal lEnd As Long)
If lStart > lEnd Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Start"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))
End If
Dim absRecordLength As Long
' see Lock description
Friend Overloads Overrides Sub Unlock(ByVal lStart As Long, ByVal lEnd As Long)
If lStart > lEnd Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Start"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))
End If
Dim absRecordLength As Long
' reading from a file that was write-only. The inner exception was added to provide more context.
If (m_access <> OpenAccess.ReadWrite) AndAlso (m_access <> OpenAccess.Read) Then
Dim JustNeedTheMessage As New NullReferenceException ' We don't have access to the localized resources for this string.
- Throw New NullReferenceException(JustNeedTheMessage.Message, New IO.IOException(GetResourceString(SR.FileOpenedNoRead)))
+ Throw New NullReferenceException(JustNeedTheMessage.Message, New IO.IOException(SR.FileOpenedNoRead))
End If
' read past any leading spaces or tabs
Dim FieldType As System.Type = field_info.FieldType
If FieldType Is Nothing Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, "Empty")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, "Empty")), vbErrors.IllegalFuncCall)
End If
If FieldType.IsArray() Then
Case TypeCode.Char
m_oFile.PutChar(0, CharType.FromObject(vValue))
Case TypeCode.DBNull
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, "DBNull")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, "DBNull")), vbErrors.IllegalFuncCall)
Case Else 'Case TypeCode.Object
If FieldType Is GetType(Object) Then
m_oFile.PutObject(vValue, 0)
ElseIf FieldType Is GetType(System.Exception) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, "Exception")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, "Exception")), vbErrors.IllegalFuncCall)
ElseIf FieldType Is GetType(System.Reflection.Missing) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, "Missing")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, "Missing")), vbErrors.IllegalFuncCall)
Else
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, FieldType.Name)), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, FieldType.Name)), vbErrors.IllegalFuncCall)
End If
End Select
End If
FieldType = field_info.FieldType
If FieldType Is Nothing Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, "Empty")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, "Empty")), vbErrors.IllegalFuncCall)
End If
If FieldType.IsArray() Then
Case TypeCode.Char
vValue = m_oFile.GetChar(0)
Case TypeCode.DBNull
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, "DBNull")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, "DBNull")), vbErrors.IllegalFuncCall)
Case Else
'Case TypeCode.Object
If FieldType Is GetType(Object) Then
m_oFile.GetObject(vValue)
ElseIf FieldType Is GetType(System.Exception) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, "Exception")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, "Exception")), vbErrors.IllegalFuncCall)
ElseIf FieldType Is GetType(System.Reflection.Missing) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, "Missing")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, "Missing")), vbErrors.IllegalFuncCall)
Else
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedFieldType2, field_info.Name, FieldType.Name)), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedFieldType2, field_info.Name, FieldType.Name)), vbErrors.IllegalFuncCall)
End If
End Select
End If
If access <> OpenAccess.Read AndAlso
access <> OpenAccess.ReadWrite AndAlso
access <> OpenAccess.Write Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Access"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Access"))
End If
m_access = access
share <> OpenShare.LockRead AndAlso
share <> OpenShare.LockReadWrite AndAlso
share <> OpenShare.LockWrite) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Share"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Share"))
End If
m_share = share
ElseIf cDims = 2 Then
SecondBound = arr.GetUpperBound(1)
ElseIf cDims <> 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_UnsupportedArrayDimensions))
+ Throw New ArgumentException(SR.Argument_UnsupportedArrayDimensions)
End If
SetRecord(RecordNumber)
ArrUBoundY = -1
ArrUBoundX = -1
ElseIf (arr.GetUpperBound(0) > FirstBound) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_ArrayDimensionsDontMatch))
+ Throw New ArgumentException(SR.Argument_ArrayDimensionsDontMatch)
End If
If typ Is Nothing Then
iUpperElementY = FirstBound
If Not arr Is Nothing Then
If arr.Rank <> 2 OrElse arr.GetUpperBound(1) <> SecondBound Then
- Throw New ArgumentException(GetResourceString(SR.Argument_ArrayDimensionsDontMatch))
+ Throw New ArgumentException(SR.Argument_ArrayDimensionsDontMatch)
End If
ArrUBoundY = arr.GetUpperBound(0)
ArrUBoundX = arr.GetUpperBound(1)
End If
End If
If FixedStringLength = 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidFixedLengthString))
+ Throw New ArgumentException(SR.Argument_InvalidFixedLengthString)
ElseIf FixedStringLength > 0 Then
FixedBlankString = StrDup(FixedStringLength, " "c)
FixedCharArray = FixedBlankString.ToCharArray() 'Used for padding
If ByteLength > System.Int16.MaxValue Then
'Size for strings is 2 bytes, thus the Short.MaxValue limitation
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.FileIO_StringLengthExceeded)), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.FileIO_StringLengthExceeded), vbErrors.IllegalFuncCall)
End If
'Do a length check and write out the length if not fixed length
Dim iUpperElementY As Integer
If arr Is Nothing Then
- Throw New ArgumentException(GetResourceString(SR.Argument_ArrayNotInitialized))
+ Throw New ArgumentException(SR.Argument_ArrayNotInitialized)
End If
If typ Is Nothing Then
arr.SetValue(obj, iElementY, iElementX)
End If
Catch Ex As IndexOutOfRangeException
- Throw New ArgumentException(GetResourceString(SR.Argument_ArrayDimensionsDontMatch))
+ Throw New ArgumentException(SR.Argument_ArrayDimensionsDontMatch)
End Try
Next iElementY
Next iElementX
ElseIf typ Is GetType(System.Reflection.Missing) Then
s = "Error 448"
Else
- Throw New ArgumentException(GetResourceString(SR.Argument_UnsupportedIOType1, VBFriendlyName(typ)))
+ Throw New ArgumentException(SR.Format(SR.Argument_UnsupportedIOType1, VBFriendlyName(typ)))
End If
End Select
End If
Private Sub ValidateReadable()
If (m_access <> OpenAccess.ReadWrite) AndAlso (m_access <> OpenAccess.Read) Then
Dim JustNeedTheMessage As New NullReferenceException ' We don't have access to the localized resources for this string.
- Throw New NullReferenceException(JustNeedTheMessage.Message, New IO.IOException(GetResourceString(SR.FileOpenedNoRead)))
+ Throw New NullReferenceException(JustNeedTheMessage.Message, New IO.IOException(SR.FileOpenedNoRead))
End If
End Sub
Friend Overloads Overrides Sub Lock(ByVal lStart As Long, ByVal lEnd As Long)
If lStart > lEnd Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Start"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))
End If
Dim lStartByte As Long
Friend Overloads Overrides Sub Unlock(ByVal lStart As Long, ByVal lEnd As Long)
If lStart > lEnd Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Start"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))
End If
Dim lStartByte As Long
ElseIf vtype = VT.DBNull AndAlso ContainedInVariant Then
Value = DBNull.Value
ElseIf vtype = VT.DBNull Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedIOType1, "DBNull")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedIOType1, "DBNull")), vbErrors.IllegalFuncCall)
ElseIf vtype = VT.Empty Then
Value = Nothing
ElseIf vtype = VT.Currency Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedIOType1, "Currency")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedIOType1, "Currency")), vbErrors.IllegalFuncCall)
Else
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedIOType1, typ.FullName)), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedIOType1, typ.FullName)), vbErrors.IllegalFuncCall)
End If
End If
End Sub
ValidateReadable()
If (Value Is Nothing) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_ArrayNotInitialized))
+ Throw New ArgumentException(SR.Argument_ArrayNotInitialized)
End If
Dim typ As Type = Value.GetType().GetElementType
ElseIf cDims = 2 Then
obj = Value.GetValue(0, 0)
Else '0 or > 2
- Throw New ArgumentException(GetResourceString(SR.Argument_UnsupportedArrayDimensions))
+ Throw New ArgumentException(SR.Argument_UnsupportedArrayDimensions)
End If
If obj Is Nothing Then
End If
If len = 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidFixedLengthString))
+ Throw New ArgumentException(SR.Argument_InvalidFixedLengthString)
End If
End If
ElseIf cDims = 2 Then
SecondBound = Value.GetUpperBound(1)
Else '0 or > 2
- Throw New ArgumentException(GetResourceString(SR.Argument_UnsupportedArrayDimensions))
+ Throw New ArgumentException(SR.Argument_UnsupportedArrayDimensions)
End If
If ArrayIsDynamic Then
typ = Value.GetType
If typ Is Nothing Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedIOType1, "Empty")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedIOType1, "Empty")), vbErrors.IllegalFuncCall)
ElseIf typ.IsArray Then
PutDynamicArray(RecordNumber, CType(Value, System.Array))
Exit Sub
End Select
If typ Is GetType(System.Reflection.Missing) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedIOType1, "Missing")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedIOType1, "Missing")), vbErrors.IllegalFuncCall)
ElseIf typ.IsValueType() AndAlso Not ContainedInVariant Then
PutRecord(RecordNumber, CType(Value, ValueType))
ElseIf ContainedInVariant AndAlso typ.IsValueType Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_PutObjectOfValueType1, VBFriendlyName(typ, Value))), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_PutObjectOfValueType1, VBFriendlyName(typ, Value))), vbErrors.IllegalFuncCall)
Else
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_UnsupportedIOType1, VBFriendlyName(typ, Value))), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_UnsupportedIOType1, VBFriendlyName(typ, Value))), vbErrors.IllegalFuncCall)
End If
End Sub
Protected Sub ValidateWriteable()
If (m_access <> OpenAccess.ReadWrite) AndAlso (m_access <> OpenAccess.Write) Then
- Throw VbMakeExceptionEx(vbErrors.PathFileAccess, GetResourceString(SR.FileOpenedNoWrite))
+ Throw VbMakeExceptionEx(vbErrors.PathFileAccess, SR.FileOpenedNoWrite)
End If
End Sub
Protected Sub ValidateReadable()
If (m_access <> OpenAccess.ReadWrite) AndAlso (m_access <> OpenAccess.Read) Then
- Throw VbMakeExceptionEx(vbErrors.PathFileAccess, GetResourceString(SR.FileOpenedNoRead))
+ Throw VbMakeExceptionEx(vbErrors.PathFileAccess, SR.FileOpenedNoRead)
End If
End Sub
Private m_CachedMember As MemberInfo
Private Sub ThrowInvalidCast(ByVal ArgType As System.Type, ByVal ParmType As System.Type, ByVal ParmIndex As Integer)
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromToArg4, CalledMethodName(), CStr(ParmIndex + 1), VBFriendlyName(ArgType), VBFriendlyName(ParmType)))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromToArg4, CalledMethodName(), CStr(ParmIndex + 1), VBFriendlyName(ArgType), VBFriendlyName(ParmType)))
End Sub
'Flags to indicate if parameter was passed
If StrComp(names(NameIndex), Parameters(ParmIndex).Name, CompareMethod.Text) = 0 Then
If ParmIndex = ParamArrayIndex AndAlso SelectedCount = 1 Then
- Throw VbMakeExceptionEx(vbErrors.NamedArgsNotSupported, GetResourceString(SR.NamedArgumentOnParamArray))
+ Throw VbMakeExceptionEx(vbErrors.NamedArgsNotSupported, SR.NamedArgumentOnParamArray)
Else
If ParmIndex = ParamArrayIndex Then
'Matched against a paramarray, force into the removal code below
' i.e. MissingMethod, MissingField, MissingMember
'This is the last possible matching member
' so throw an exception that the name doesn't match
- Throw New MissingMemberException(GetResourceString(SR.Argument_InvalidNamedArg2, names(NameIndex), CalledMethodName()))
+ Throw New MissingMemberException(SR.Format(SR.Argument_InvalidNamedArg2, names(NameIndex), CalledMethodName()))
End If
match(MethodIndex) = Nothing
If (ParamArrayIndex = PARAMARRAY_NONE) AndAlso (args.Length > Parameters.Length) Then
'If we have too many arguments, we don't match any function
If SelectedCount = 1 Then
- Throw New MissingMemberException(GetResourceString(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
+ Throw New MissingMemberException(SR.Format(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
End If
'Clear this entry
If (j <> LengthOfNonParamArrayArguments) Then
'Not enough arguments to call this method, so remove it
If SelectedCount = 1 Then
- Throw New MissingMemberException(GetResourceString(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
+ Throw New MissingMemberException(SR.Format(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
End If
match(MethodIndex) = Nothing
SelectedCount -= 1
GoTo NextParm7
Else
If SelectedCount = 1 Then
- Throw New MissingMemberException(GetResourceString(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
+ Throw New MissingMemberException(SR.Format(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
End If
GoTo ClearMethod7
End If
If InitialMemberCount = 1 Then
ThrowInvalidCast(ArgType, ParmType, ParmIndex)
Else
- Throw New AmbiguousMatchException(GetResourceString(SR.AmbiguousMatch_NarrowingConversion1, CalledMethodName()))
+ Throw New AmbiguousMatchException(SR.Format(SR.AmbiguousMatch_NarrowingConversion1, CalledMethodName()))
End If
End If
match(MethodIndex) = Nothing
Next
If (SelectedCount = 0) Then
- Throw New MissingMemberException(GetResourceString(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
+ Throw New MissingMemberException(SR.Format(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
End If
state = New VBBinderState
Select Case LowestScore
Case BindScore.Exact
- Throw New AmbiguousMatchException(GetResourceString(SR.AmbiguousCall_ExactMatch2, CalledMethodName(), Msg))
+ Throw New AmbiguousMatchException(SR.Format(SR.AmbiguousCall_ExactMatch2, CalledMethodName(), Msg))
Case BindScore.Widening0, BindScore.Widening1
- Throw New AmbiguousMatchException(GetResourceString(SR.AmbiguousCall_WideningConversion2, CalledMethodName(), Msg))
+ Throw New AmbiguousMatchException(SR.Format(SR.AmbiguousCall_WideningConversion2, CalledMethodName(), Msg))
Case Else
'BindScore.Narrowing
'BindScore.Unknown
- Throw New AmbiguousMatchException(GetResourceString(SR.AmbiguousCall2, CalledMethodName(), Msg))
+ Throw New AmbiguousMatchException(SR.Format(SR.AmbiguousCall2, CalledMethodName(), Msg))
End Select
End If
'
Debug.Assert(Not SelectedMatch Is Nothing, "Should have already thrown an exception")
If SelectedMatch Is Nothing Then
- Throw New MissingMemberException(GetResourceString(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
+ Throw New MissingMemberException(SR.Format(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, IsPropertySet))))
End If
Return SelectedMatch
Return ObjectType.CTypeHelper(value, typ)
End If
Catch ex As Exception
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(value), VBFriendlyName(typ)))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(value), VBFriendlyName(typ)))
End Try
End Function
If StrComp(names(i), pars(j).Name, CompareMethod.Text) = 0 Then
If paramOrder(j) <> -1 Then
- Return New ArgumentException(GetResourceString(SR.NamedArgumentAlreadyUsed1, pars(j).Name))
+ Return New ArgumentException(SR.Format(SR.NamedArgumentAlreadyUsed1, pars(j).Name))
End If
paramOrder(j) = i
' method must not match what we sent.
If (j > LastNonSetIndex) Then
'Should no longer hit this, since we removed all these cases in a previous step
- Return New MissingMemberException(GetResourceString(SR.Argument_InvalidNamedArg2, names(i), CalledMethodName()))
+ Return New MissingMemberException(SR.Format(SR.Argument_InvalidNamedArg2, names(i), CalledMethodName()))
End If
Next i
'END: SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY SECURITY
'
Catch ex As MissingMemberException
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_MemberNotFoundOnType2, name, VBFriendlyName(objType)))
End Try
End If
If (objType Is objIReflect) Then
name = GetDefaultMemberName(objType)
If (name Is Nothing) Then
- Throw New MissingMemberException(GetResourceString(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType)))
+ Throw New MissingMemberException(SR.Format(SR.MissingMember_NoDefaultMemberFound1, VBFriendlyName(objType)))
End If
Else
' IReflect case, we pass in empty string so that user implementation can return default members determined at run time
Dim binderState As Object = Nothing
invokeMethod = Me.BindToMethod(invokeAttr, p, args, Nothing, Nothing, namedParameters, binderState)
If (invokeMethod Is Nothing) Then
- Throw New MissingMemberException(GetResourceString(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, (invokeAttr And BindingFlags.SetProperty) <> 0))))
+ Throw New MissingMemberException(SR.Format(SR.NoMethodTakingXArguments2, CalledMethodName(), CStr(GetPropArgCount(args, (invokeAttr And BindingFlags.SetProperty) <> 0))))
End If
'
Next j
If RemovedCount = mi.Length - 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_IllegalNestedType2, name, VBFriendlyName(objType)))
+ Throw New ArgumentException(SR.Format(SR.Argument_IllegalNestedType2, name, VBFriendlyName(objType)))
End If
mi(MemberIndex) = Nothing 'Remove the nested class, since we cannot use it
RemovedCount += 1
Return Nothing
Case Else
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "CallType"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "CallType"))
End Select
End Function
Public Function ErrorToString(ByVal ErrorNumber As Integer) As String
If ErrorNumber >= MAX_ERR_NUMBER Then
- Throw New ArgumentException(GetResourceString(SR.MaxErrNumber))
+ Throw New ArgumentException(SR.MaxErrNumber)
End If
If ErrorNumber > 0 Then
Public Function Fix(ByVal Number As Object) As Object
If Number Is Nothing Then
- Throw New ArgumentNullException(GetResourceString(SR.Argument_InvalidNullValue1, "Number"))
+ Throw New ArgumentNullException(SR.Format(SR.Argument_InvalidNullValue1, "Number"))
End If
Dim ValueInterface As IConvertible
End If
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_NotNumericType2, NameOf(Number), Number.GetType().FullName)), vbErrors.TypeMismatch)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_NotNumericType2, NameOf(Number), Number.GetType().FullName)), vbErrors.TypeMismatch)
End Function
Public Function Int(ByVal Number As Short) As Short
Public Function Int(ByVal Number As Object) As Object
If Number Is Nothing Then
- Throw New ArgumentNullException(GetResourceString(SR.Argument_InvalidNullValue1, NameOf(Number)))
+ Throw New ArgumentNullException(SR.Format(SR.Argument_InvalidNullValue1, NameOf(Number)))
End If
Dim ValueInterface As IConvertible
End Select
End If
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_NotNumericType2, NameOf(Number), Number.GetType().FullName)), vbErrors.TypeMismatch)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_NotNumericType2, NameOf(Number), Number.GetType().FullName)), vbErrors.TypeMismatch)
End Function
'============================================================================
Dim LongValue As Long
If Number Is Nothing Then
- Throw New ArgumentNullException(GetResourceString(SR.Argument_InvalidNullValue1, NameOf(Number)))
+ Throw New ArgumentNullException(SR.Format(SR.Argument_InvalidNullValue1, NameOf(Number)))
End If
Dim ValueInterface As IConvertible
End Select
End If
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValueType2, NameOf(Number), VBFriendlyName(Number)))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValueType2, NameOf(Number), VBFriendlyName(Number)))
End Function
<CLSCompliant(False)>
Dim LongValue As Long
If Number Is Nothing Then
- Throw New ArgumentNullException(GetResourceString(SR.Argument_InvalidNullValue1, NameOf(Number)))
+ Throw New ArgumentNullException(SR.Format(SR.Argument_InvalidNullValue1, NameOf(Number)))
End If
Dim ValueInterface As IConvertible
End Select
End If
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValueType2, NameOf(Number), VBFriendlyName(Number)))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValueType2, NameOf(Number), VBFriendlyName(Number)))
End Function
Public Function Str(ByVal Number As Object) As String
Dim s As String
If Number Is Nothing Then
- Throw New ArgumentNullException(GetResourceString(SR.Argument_InvalidNullValue1, NameOf(Number)))
+ Throw New ArgumentNullException(SR.Format(SR.Argument_InvalidNullValue1, NameOf(Number)))
End If
Dim ValueInterface As IConvertible
ValueInterface = TryCast(Number, IConvertible)
If ValueInterface Is Nothing Then
- Throw New InvalidCastException(GetResourceString(SR.ArgumentNotNumeric1, NameOf(Number)))
+ Throw New InvalidCastException(SR.Format(SR.ArgumentNotNumeric1, NameOf(Number)))
End If
ValueTypeCode = ValueInterface.GetTypeCode()
'Throw our own exception below
End Try
End If
- Throw New InvalidCastException(GetResourceString(SR.ArgumentNotNumeric1, NameOf(Number)))
+ Throw New InvalidCastException(SR.Format(SR.ArgumentNotNumeric1, NameOf(Number)))
End Select
FormatAndExit:
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValueType2, NameOf(Expression), VBFriendlyName(Expression))), vbErrors.OLENoPropOrMethod)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValueType2, NameOf(Expression), VBFriendlyName(Expression))), vbErrors.OLENoPropOrMethod)
End Try
Return Val(sValue)
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw VbMakeException(New InvalidCastException(GetResourceString(SR.InvalidCast_FromStringTo, Left(Value, 32), "Date")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New InvalidCastException(SR.Format(SR.InvalidCast_FromStringTo, Left(Value, 32), "Date")), vbErrors.IllegalFuncCall)
End Try
SetTime(dt)
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw VbMakeException(New InvalidCastException(GetResourceString(SR.InvalidCast_FromStringTo, Left(Value, 32), "Date")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New InvalidCastException(SR.Format(SR.InvalidCast_FromStringTo, Left(Value, 32), "Date")), vbErrors.IllegalFuncCall)
End Try
SetDate(NewDate)
Return DateValue.AddMonths(lNumber * 3)
End Select
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Interval"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Interval"))
End Function
Public Function DateDiff(ByVal Interval As DateInterval,
Return (cal.GetYear(Date2) - cal.GetYear(Date1)) * 4 + (cal.GetMonth(Date2) - 1) \ 3 - (cal.GetMonth(Date1) - 1) \ 3
End Select
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Interval"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Interval"))
End Function
Private Function GetDayOfWeek(ByVal dt As Date, ByVal weekdayFirst As FirstDayOfWeek) As Integer
Return CurrentCalendar.GetDayOfYear(DateValue)
End Select
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Interval"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Interval"))
End Function
Public Function DateAdd(ByVal Interval As String,
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New InvalidCastException(GetResourceString(SR.Argument_InvalidDateValue1, "DateValue"))
+ Throw New InvalidCastException(SR.Format(SR.Argument_InvalidDateValue1, "DateValue"))
End Try
Return DateAdd(DateIntervalFromString(Interval), Number, dt1)
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New InvalidCastException(GetResourceString(SR.Argument_InvalidDateValue1, "Date1"))
+ Throw New InvalidCastException(SR.Format(SR.Argument_InvalidDateValue1, "Date1"))
End Try
Try
dt2 = CDate(Date2)
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New InvalidCastException(GetResourceString(SR.Argument_InvalidDateValue1, "Date2"))
+ Throw New InvalidCastException(SR.Format(SR.Argument_InvalidDateValue1, "Date2"))
End Try
Return DateDiff(DateIntervalFromString(Interval), dt1, dt2, DayOfWeek, WeekOfYear)
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New InvalidCastException(GetResourceString(SR.Argument_InvalidDateValue1, "DateValue"))
+ Throw New InvalidCastException(SR.Format(SR.Argument_InvalidDateValue1, "DateValue"))
End Try
Return DatePart(DateIntervalFromString(Interval), dt1, DayOfWeek, WeekOfYear)
Case "Q"
Return DateInterval.Quarter
Case Else
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Interval"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Interval"))
End Select
End Function
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Year")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Year")), vbErrors.IllegalFuncCall)
End Try
Try
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Month")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Month")), vbErrors.IllegalFuncCall)
End Try
Try
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Day")), vbErrors.IllegalFuncCall)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Day")), vbErrors.IllegalFuncCall)
End Try
Return Result
DayOfWeek = CType(DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek + 1, FirstDayOfWeek)
ElseIf (DayOfWeek < FirstDayOfWeek.Sunday) OrElse (DayOfWeek > FirstDayOfWeek.Saturday) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "DayOfWeek"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "DayOfWeek"))
End If
'Get the day from the date
Dim Result As String
If Month < 1 OrElse Month > 13 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Month"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Month"))
End If
If Abbreviate Then
End If
If Result.Length = 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Month"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Month"))
End If
Return Result
Dim Result As String
If (Weekday < 1) OrElse (Weekday > 7) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Weekday"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Weekday"))
End If
If (FirstDayOfWeekValue < 0) OrElse (FirstDayOfWeekValue > 7) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "FirstDayOfWeekValue"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "FirstDayOfWeekValue"))
End If
dtfi = CType(GetCultureInfo().GetFormat(GetType(System.Globalization.DateTimeFormatInfo)), DateTimeFormatInfo) 'Returns a read-only object
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Weekday"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Weekday"))
End Try
If Result.Length = 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Weekday"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Weekday"))
End If
Return Result
Dim tmpNumber As Integer = Me.Number
If Msg Is Nothing OrElse Msg.Length = 0 Then
- Msg = GetResourceString("ID" & CStr(tmpNumber))
+ Msg = SR.GetResourceString("ID" & CStr(tmpNumber))
ElseIf System.String.CompareOrdinal("Exception from HRESULT: 0x", 0, Msg, 0, Math.Min(Msg.Length, 26)) = 0 Then
- NewMsg = GetResourceString("ID" & CStr(m_curNumber))
+ NewMsg = SR.GetResourceString("ID" & CStr(m_curNumber))
If Not NewMsg Is Nothing Then
Msg = NewMsg
End If
If Number = 0 Then
'This is only called by Raise, so Raise(0) should give the following exception
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Number"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Number"))
End If
Me.Number = Number
If Number = 0 Then
'This is only called by Error xxxx, zero is not a valid exception number
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Number"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Number"))
End If
Dim e As Exception = MapNumberToException(m_curNumber, Description)
Friend Function MapErrorNumber(ByVal Number As Integer) As Integer
If Number > 65535 Then
' Number cannot be greater than 65535.
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1), "Number")
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1), "Number")
End If
If Number >= 0 Then
' Throw the final exception if there were exceptions during copy / move.
If Exceptions.Count > 0 Then
- Dim IOException As New IO.IOException(Utils.GetResourceString(SR.IO_CopyMoveRecursive))
+ Dim IOException As New IO.IOException(SR.IO_CopyMoveRecursive)
For Each Entry As DictionaryEntry In Exceptions
IOException.Data.Add(Entry.Key, Entry.Value)
Next
''' <returns>The base ToString plus the Line Number</returns>
''' <remarks></remarks>
Public Overrides Function ToString() As String
- Return MyBase.ToString() & " " & GetResourceString(SR.TextFieldParser_MalformedExtraData, LineNumber.ToString(CultureInfo.InvariantCulture))
+ Return MyBase.ToString() & " " & SR.Format(SR.TextFieldParser_MalformedExtraData, LineNumber.ToString(CultureInfo.InvariantCulture))
End Function
' Holds the line number
Private Shared Function GetDirectoryPath(ByVal Directory As String, ByVal DirectoryNameResID As String) As String
' Only need to worry about Directory being "" since it comes from Framework.
If Directory = "" Then
- Throw ExUtils.GetDirectoryNotFoundException(SR.IO_SpecialDirectoryNotExist, GetResourceString(DirectoryNameResID))
+ Throw ExUtils.GetDirectoryNotFoundException(SR.IO_SpecialDirectoryNotExist, DirectoryNameResID)
End If
Return FileSystem.NormalizePath(Directory)
End Function
' Make sure the file exists
If Not File.Exists(fullPath) Then
- Throw New IO.FileNotFoundException(GetResourceString(SR.IO_FileNotFound_Path, fullPath))
+ Throw New IO.FileNotFoundException(SR.Format(SR.IO_FileNotFound_Path, fullPath))
End If
Return fullPath
If EndHelper.MalformedLine Then
m_ErrorLine = Line.TrimEnd(Chr(13), Chr(10))
m_ErrorLineNumber = CurrentLineNumber
- Throw New MalformedLineException(GetResourceString(SR.TextFieldParser_MalFormedDelimitedLine, CurrentLineNumber.ToString(CultureInfo.InvariantCulture)), CurrentLineNumber)
+ Throw New MalformedLineException(SR.Format(SR.TextFieldParser_MalFormedDelimitedLine, CurrentLineNumber.ToString(CultureInfo.InvariantCulture)), CurrentLineNumber)
End If
If EndHelper.FieldFinished Then
If NewLine Is Nothing Then
m_ErrorLine = Line.TrimEnd(Chr(13), Chr(10))
m_ErrorLineNumber = CurrentLineNumber
- Throw New MalformedLineException(GetResourceString(SR.TextFieldParser_MalFormedDelimitedLine, CurrentLineNumber.ToString(CultureInfo.InvariantCulture)), CurrentLineNumber)
+ Throw New MalformedLineException(SR.Format(SR.TextFieldParser_MalFormedDelimitedLine, CurrentLineNumber.ToString(CultureInfo.InvariantCulture)), CurrentLineNumber)
End If
If Line.Length + NewLine.Length > m_MaxLineSize Then
m_ErrorLine = Line.TrimEnd(Chr(13), Chr(10))
m_ErrorLineNumber = CurrentLineNumber
- Throw New MalformedLineException(GetResourceString(SR.TextFieldParser_MaxLineSizeExceeded, CurrentLineNumber.ToString(CultureInfo.InvariantCulture)), CurrentLineNumber)
+ Throw New MalformedLineException(SR.Format(SR.TextFieldParser_MaxLineSizeExceeded, CurrentLineNumber.ToString(CultureInfo.InvariantCulture)), CurrentLineNumber)
End If
Line &= NewLine
If EndHelper.MalformedLine Then
m_ErrorLine = Line.TrimEnd(Chr(13), Chr(10))
m_ErrorLineNumber = CurrentLineNumber
- Throw New MalformedLineException(GetResourceString(SR.TextFieldParser_MalFormedDelimitedLine, CurrentLineNumber.ToString(CultureInfo.InvariantCulture)), CurrentLineNumber)
+ Throw New MalformedLineException(SR.Format(SR.TextFieldParser_MalFormedDelimitedLine, CurrentLineNumber.ToString(CultureInfo.InvariantCulture)), CurrentLineNumber)
End If
Loop Until EndHelper.FieldFinished
If Line.LengthInTextElements < m_LineLength Then
m_ErrorLine = Line.String
m_ErrorLineNumber = m_LineNumber - 1
- Throw New MalformedLineException(GetResourceString(SR.TextFieldParser_MalFormedFixedWidthLine, LineNumber.ToString(CultureInfo.InvariantCulture)), LineNumber)
+ Throw New MalformedLineException(SR.Format(SR.TextFieldParser_MalFormedFixedWidthLine, LineNumber.ToString(CultureInfo.InvariantCulture)), LineNumber)
End If
End Sub
Path = RTrim(Path) 'VB6 accepted things like "\ ", so need to trim the trailing spaces
If (Path Is Nothing) OrElse (Path.Length = 0) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_PathNullOrEmpty)), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Argument_PathNullOrEmpty), vbErrors.BadFileNameOrNumber)
End If
' Do this since System.IO.Directory does not accept "\"
Try
System.IO.Directory.SetCurrentDirectory(Path)
Catch ex As System.IO.FileNotFoundException
- Throw VbMakeException(New FileNotFoundException(GetResourceString(SR.FileSystem_PathNotFound1, Path)), vbErrors.PathNotFound)
+ Throw VbMakeException(New FileNotFoundException(SR.Format(SR.FileSystem_PathNotFound1, Path)), vbErrors.PathNotFound)
End Try
End Sub
Drive = System.Char.ToUpper(Drive, CultureInfo.InvariantCulture)
If (Drive < chLetterA) OrElse (Drive > chLetterZ) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Drive"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Drive"))
End If
If Not UnsafeValidDrive(Drive) Then
- Throw VbMakeException(New IOException(GetResourceString(SR.FileSystem_DriveNotFound1, CStr(Drive))), vbErrors.DevUnavailable)
+ Throw VbMakeException(New IOException(SR.Format(SR.FileSystem_DriveNotFound1, CStr(Drive))), vbErrors.DevUnavailable)
End If
IO.Directory.SetCurrentDirectory(Drive & Path.VolumeSeparatorChar)
Drive = System.Char.ToUpper(Drive, CultureInfo.InvariantCulture)
If (Drive < chLetterA OrElse Drive > chLetterZ) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Drive")), vbErrors.DevUnavailable)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Drive")), vbErrors.DevUnavailable)
End If
'GetFullPath("x:.") will return the full directory path
Dim CurrentPath As String = Path.GetFullPath(Drive & Path.VolumeSeparatorChar & ".")
If Not UnsafeValidDrive(Drive) Then
- Throw VbMakeException(New IOException(GetResourceString(SR.FileSystem_DriveNotFound1, CStr(Drive))), vbErrors.DevUnavailable)
+ Throw VbMakeException(New IOException(SR.Format(SR.FileSystem_DriveNotFound1, CStr(Drive))), vbErrors.DevUnavailable)
End If
Return CurrentPath
End Function
"Methods in Microsoft.VisualBasic should not call FileSystem public method.")
If Path Is Nothing OrElse Path.Length = 0 Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_PathNullOrEmpty)), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Argument_PathNullOrEmpty), vbErrors.BadFileNameOrNumber)
End If
If Directory.Exists(Path) Then
'If null or empty directory, give error
If Path Is Nothing OrElse Path.Length = 0 Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_PathNullOrEmpty)), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Argument_PathNullOrEmpty), vbErrors.BadFileNameOrNumber)
End If
Try
Public Sub FileCopy(ByVal Source As String, ByVal Destination As String)
If (Source Is Nothing) OrElse (Source.Length = 0) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_PathNullOrEmpty1, "Source")), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_PathNullOrEmpty1, "Source")), vbErrors.BadFileNameOrNumber)
End If
If (Destination Is Nothing) OrElse (Destination.Length = 0) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_PathNullOrEmpty1, "Destination")), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_PathNullOrEmpty1, "Destination")), vbErrors.BadFileNameOrNumber)
End If
' Error if wildcard characters in name
If PathContainsWildcards(Source) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Source")), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Source")), vbErrors.BadFileNameOrNumber)
End If
If PathContainsWildcards(Destination) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Destination")), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Destination")), vbErrors.BadFileNameOrNumber)
End If
Dim oAssemblyData As AssemblyData = ProjectData.GetProjectData().GetAssemblyData(System.Reflection.Assembly.GetCallingAssembly())
If CheckFileOpen(oAssemblyData, Destination, OpenModeTypes.Output) Then
- Throw VbMakeException(New IOException(GetResourceString(SR.FileSystem_FileAlreadyOpen1, Destination)), vbErrors.FileAlreadyOpen)
+ Throw VbMakeException(New IOException(SR.Format(SR.FileSystem_FileAlreadyOpen1, Destination)), vbErrors.FileAlreadyOpen)
End If
If CheckFileOpen(oAssemblyData, Source, OpenModeTypes.Input) Then
- Throw VbMakeException(New IOException(GetResourceString(SR.FileSystem_FileAlreadyOpen1, Source)), vbErrors.FileAlreadyOpen)
+ Throw VbMakeException(New IOException(SR.Format(SR.FileSystem_FileAlreadyOpen1, Source)), vbErrors.FileAlreadyOpen)
End If
Try
"Methods in Microsoft.VisualBasic should not call FileSystem public method.")
If PathContainsWildcards(PathName) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "PathName")), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "PathName")), vbErrors.BadFileNameOrNumber)
End If
If File.Exists(PathName) Then
Return (New FileInfo(PathName)).LastWriteTime
End If
- Throw New FileNotFoundException(GetResourceString(SR.FileSystem_FileNotFound1, PathName))
+ Throw New FileNotFoundException(SR.Format(SR.FileSystem_FileNotFound1, PathName))
End Function
Public Function FileLen(ByVal PathName As String) As Long
Return (New FileInfo(PathName)).Length
End If
- Throw New FileNotFoundException(GetResourceString(SR.FileSystem_FileNotFound1, PathName))
+ Throw New FileNotFoundException(SR.Format(SR.FileSystem_FileNotFound1, PathName))
End Function
Public Function GetAttr(ByVal PathName As String) As FileAttribute
If Path.GetFileName(PathName).Length = 0 Then
Throw VbMakeException(vbErrors.BadFileNameOrNumber)
Else
- Throw New FileNotFoundException(GetResourceString(SR.FileSystem_FileNotFound1, PathName))
+ Throw New FileNotFoundException(SR.Format(SR.FileSystem_FileNotFound1, PathName))
End If
End Function
' error if file is presently open
Dim oAssemblyData As AssemblyData = ProjectData.GetProjectData().GetAssemblyData(System.Reflection.Assembly.GetCallingAssembly())
If CheckFileOpen(oAssemblyData, FileName, OpenModeTypes.Any) Then
- Throw VbMakeException(New IOException(GetResourceString(SR.FileSystem_FileAlreadyOpen1, FileName)), vbErrors.FileAlreadyOpen)
+ Throw VbMakeException(New IOException(SR.Format(SR.FileSystem_FileAlreadyOpen1, FileName)), vbErrors.FileAlreadyOpen)
End If
Try
End If
If DeleteCount = 0 Then
- Throw New IO.FileNotFoundException(GetResourceString(SR.KILL_NoFilesFound1, PathName))
+ Throw New IO.FileNotFoundException(SR.Format(SR.KILL_NoFilesFound1, PathName))
End If
End Sub
'Check pathname for errors and if file is open for any mode except sequential input
If (PathName Is Nothing) OrElse (PathName.Length = 0) Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_PathNullOrEmpty)), vbErrors.BadFileNameOrNumber)
+ Throw VbMakeException(New ArgumentException(SR.Argument_PathNullOrEmpty), vbErrors.BadFileNameOrNumber)
End If
Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly()
'Only allow _A_RDONLY(1), _A_HIDDEN(2), _A_SYSTEM(4), _A_ARCH(20)
If ((Attributes Or &H27S) <> &H27S) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Attributes"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Attributes"))
End If
'Dir function always returns files with Normal attribute in addition to others specified.
Access <> OpenAccess.Read AndAlso
Access <> OpenAccess.ReadWrite AndAlso
Access <> OpenAccess.Write Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Access"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Access"))
End If
End Sub
Share <> OpenShare.LockRead AndAlso
Share <> OpenShare.LockReadWrite AndAlso
Share <> OpenShare.LockWrite Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Share"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Share"))
End If
End Sub
Mode <> OpenMode.Random AndAlso
Mode <> OpenMode.Append AndAlso
Mode <> OpenMode.Binary Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Mode"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Mode"))
End If
End Sub
Private Sub ValidateGetPutRecordNumber(ByVal RecordNumber As Long)
If RecordNumber < 1 AndAlso RecordNumber <> -1 Then
- Throw VbMakeException(New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "RecordNumber")), vbErrors.BadRecordNum)
+ Throw VbMakeException(New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "RecordNumber")), vbErrors.BadRecordNum)
End If
End Sub
<ObsoleteAttribute("This member has been deprecated. Please use FilePutObject to write Object types, or coerce FileNumber and RecordNumber to Integer for writing non-Object types. http://go.microsoft.com/fwlink/?linkid=14202")>
Public Sub FilePut(ByVal FileNumber As Object, ByVal Value As Object, Optional ByVal RecordNumber As Object = -1)
- Throw New ArgumentException(GetResourceString(SR.UseFilePutObject))
+ Throw New ArgumentException(SR.UseFilePutObject)
End Sub
Public Sub FilePut(ByVal FileNumber As Integer, ByVal Value As ValueType, Optional ByVal RecordNumber As Long = -1)
Dim oFile As VB6File
If (CharCount < 0 OrElse CharCount > (&H7FFFFFFFI / 2)) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "CharCount"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "CharCount"))
End If
Dim assem As System.Reflection.Assembly = System.Reflection.Assembly.GetCallingAssembly()
' This exception should never be hit.
' We will throw Arguments are not valid.
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue), "om")
+ Throw New ArgumentException(SR.Argument_InvalidValue, "om")
End Function
Friend Sub CloseAllFiles(ByVal assem As System.Reflection.Assembly)
Dim Result As String
' Error if wildcard characters in pathname
If (sPath.IndexOf("?"c) <> -1 OrElse sPath.IndexOf("*"c) <> -1) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidPathChars1, sPath))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidPathChars1, sPath))
End If
' process the name to check for errors
Case OpenMode.Input
If (Access <> OpenAccess.Read) AndAlso (Access <> OpenAccess.Default) Then
- Throw New ArgumentException(GetResourceString(SR.FileSystem_IllegalInputAccess))
+ Throw New ArgumentException(SR.FileSystem_IllegalInputAccess)
End If
oFile = New VB6InputFile(FileName, Share)
Case OpenMode.Output
If (Access <> OpenAccess.Write) AndAlso (Access <> OpenAccess.Default) Then
- Throw New ArgumentException(GetResourceString(SR.FileSystem_IllegalOutputAccess))
+ Throw New ArgumentException(SR.FileSystem_IllegalOutputAccess)
End If
oFile = New VB6OutputFile(FileName, Share, False)
Case OpenMode.Random
oFile = New VB6RandomFile(FileName, Access, Share, RecordLength)
Case OpenMode.Append
If (Access <> OpenAccess.Write) AndAlso (Access <> OpenAccess.ReadWrite) AndAlso (Access <> OpenAccess.Default) Then
- Throw New ArgumentException(GetResourceString(SR.FileSystem_IllegalAppendAccess))
+ Throw New ArgumentException(SR.FileSystem_IllegalAppendAccess)
End If
oFile = New VB6OutputFile(FileName, Share, True)
Case OpenMode.Binary
' Handle invalid parameters
If Factor <= 0.0# OrElse Salvage < 0.0# OrElse Period <= 0.0# OrElse Period > Life Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Factor"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Factor"))
End If
' Handle special (trivial) cases
' Type = 0 or non-zero only. Offset to calculate FV
If (Per <= 0.0#) OrElse (Per >= NPer + 1) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Per"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Per"))
End If
If (Due <> DueDate.EndOfPeriod) AndAlso (Per = 1.0#) Then
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "ValueArray"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "ValueArray"))
End Try
lCVal = lUpper + 1
'Function fails for invalid parameters
If Guess <= (-1.0#) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Guess"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Guess"))
End If
If lCVal <= 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "ValueArray"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "ValueArray"))
End If
'We scale the epsilon depending on cash flow values. It is necessary
End If
If dRate1 <= (-1.0#) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Rate"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Rate"))
End If
dNpv1 = OptPV2(ValueArray, dRate1)
End If
dNPv0 = OptPV2(ValueArray, dRate0)
If dNpv1 = dNPv0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
End If
dRate1 = dTemp
Next lIndex
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End Function
'-------------------------------------------------------------
Dim lUpper As Integer
If ValueArray.Rank <> 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_RankEQOne1, "ValueArray"))
+ Throw New ArgumentException(SR.Format(SR.Argument_RankEQOne1, "ValueArray"))
End If
lLower = 0
lCVal = lUpper - lLower + 1
If FinanceRate = -1.0# Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "FinanceRate"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "FinanceRate"))
End If
If ReinvestRate = -1.0# Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "ReinvestRate"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "ReinvestRate"))
End If
If lCVal <= 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "ValueArray"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "ValueArray"))
End If
dNpvNeg = LDoNPV(FinanceRate, ValueArray, -1)
If dNpvNeg = 0.0# Then
- Throw New DivideByZeroException(GetResourceString(SR.Financial_CalcDivByZero))
+ Throw New DivideByZeroException(SR.Financial_CalcDivByZero)
End If
dNpvPos = LDoNPV(ReinvestRate, ValueArray, 1) ' npv of +ve values
dTemp = -dNpvPos * dTemp1 ^ dNTemp2 / (dNpvNeg * (FinanceRate + 1.0#))
If dTemp < 0.0# Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
dTemp1 = 1 / (lCVal - 1.0#)
' Checking Error Conditions
If Rate <= -1.0# Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Rate"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Rate"))
End If
If Rate = 0.0# Then
If Pmt = 0.0# Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Pmt"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Pmt"))
End If
Return (-(PV + FV) / Pmt)
Else
dTempFv = -1 * dTempFv
dTempPv = -1 * dTempPv
ElseIf dTempFv <= 0.0# OrElse dTempPv <= 0.0# Then
- Throw New ArgumentException(GetResourceString(SR.Financial_CannotCalculateNPer))
+ Throw New ArgumentException(SR.Financial_CannotCalculateNPer)
End If
dTemp4 = Rate + 1.0#
Dim lUpper As Integer
If (ValueArray Is Nothing) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidNullValue1, "ValueArray"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidNullValue1, "ValueArray"))
End If
If ValueArray.Rank <> 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_RankEQOne1, "ValueArray"))
+ Throw New ArgumentException(SR.Format(SR.Argument_RankEQOne1, "ValueArray"))
End If
lLower = 0
lCVal = lUpper - lLower + 1
If Rate = (-1.0#) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Rate"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Rate"))
End If
If lCVal < 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "ValueArray"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "ValueArray"))
End If
NPV = LDoNPV(Rate, ValueArray, 0)
' Checking for error conditions
If NPer = 0.0# Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "NPer"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "NPer"))
End If
If Rate = 0.0# Then
' Checking for error conditions
If (Per <= 0.0#) OrElse (Per >= (NPer + 1)) Then
- Throw New ArgumentException(GetResourceString(SR.PPMT_PerGT0AndLTNPer, "Per"))
+ Throw New ArgumentException(SR.Format(SR.PPMT_PerGT0AndLTNPer, "Per"))
End If
Pmt = PMT_Internal(Rate, NPer, PV, FV, Due)
' Check for error condition
If NPer <= 0.0# Then
- Throw New ArgumentException(GetResourceString(SR.Rate_NPerMustBeGTZero))
+ Throw New ArgumentException(SR.Rate_NPerMustBeGTZero)
End If
dRate0 = Guess
End If
dY0 = LEvalRate(dRate0, NPer, Pmt, PV, FV, Due)
If dY1 = dY0 Then
- Throw New ArgumentException(GetResourceString(SR.Financial_CalcDivByZero))
+ Throw New ArgumentException(SR.Financial_CalcDivByZero)
End If
End If
dRate1 = dTemp
Next I
- Throw New ArgumentException(GetResourceString(SR.Financial_CannotCalculateRate))
+ Throw New ArgumentException(SR.Financial_CannotCalculateRate)
End Function
Public Function SLN(ByVal Cost As Double, ByVal Salvage As Double, ByVal Life As Double) As Double
If Life = 0.0# Then
- Throw New ArgumentException(GetResourceString(SR.Financial_LifeNEZero))
+ Throw New ArgumentException(SR.Financial_LifeNEZero)
End If
Return (Cost - Salvage) / (Life)
Dim Result As Double
If Salvage < 0.0# Then
- Throw New ArgumentException(GetResourceString(SR.Financial_ArgGEZero1, "Salvage"))
+ Throw New ArgumentException(SR.Format(SR.Financial_ArgGEZero1, "Salvage"))
End If
If Period > Life Then
- Throw New ArgumentException(GetResourceString(SR.Financial_PeriodLELife))
+ Throw New ArgumentException(SR.Financial_PeriodLELife)
End If
If Period <= 0.0# Then
- Throw New ArgumentException(GetResourceString(SR.Financial_ArgGTZero1, "Period"))
+ Throw New ArgumentException(SR.Format(SR.Financial_ArgGTZero1, "Period"))
End If
'Avoid OverflowExceptions by dividing before multiplying
'Validate index - Note that unlike the fx, this is a legacy VB function and the index is 1 based.
If Expression <= 0 OrElse Expression > 255 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_Range1toFF1, "Expression"))
+ Throw New ArgumentException(SR.Format(SR.Argument_Range1toFF1, "Expression"))
End If
If m_SortedEnvList Is Nothing Then
Expression = Trim(Expression)
If Expression.Length = 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Expression"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Expression"))
End If
Return Environment.GetEnvironmentVariable(Expression)
Dim FixedIndex As Integer = CInt(Fix(Index) - 1) 'ParamArray is 0 based, but Choose assumes 1 based
If Choice.Rank <> 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_RankEQOne1, "Choice"))
+ Throw New ArgumentException(SR.Format(SR.Argument_RankEQOne1, "Choice"))
ElseIf FixedIndex < 0 OrElse FixedIndex > Choice.GetUpperBound(0) Then
Return Nothing
End If
'Validate arguments
If Start < 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Start"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Start"))
End If
If [Stop] <= Start Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Stop"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Stop"))
End If
If Interval < 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Interval"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Interval"))
End If
'Check for before-first and after-last ranges
'Ensure we have an even number of arguments (0 based)
If (Elements Mod 2) <> 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "VarExpr"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "VarExpr"))
End If
Do While Elements > 0
Else
AppSectionKey = UserKey.OpenSubKey(AppSection, True)
If AppSectionKey Is Nothing Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Section"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Section"))
End If
AppSectionKey.DeleteValue(Key)
ElseIf TypeOf o Is String Then ' - odd that this is required to be a string when it isn't in GetAllSettings() above...
Return DirectCast(o, String)
Else
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue))
+ Throw New ArgumentException(SR.Argument_InvalidValue)
End If
End Function
If rk Is Nothing Then
'Subkey could not be created
- Throw New ArgumentException(GetResourceString(SR.Interaction_ResKeyNotCreated1, sIniSect))
+ Throw New ArgumentException(SR.Format(SR.Interaction_ResKeyNotCreated1, sIniSect))
End If
Try
Private Sub CheckPathComponent(ByVal s As String)
If (s Is Nothing) OrElse (s.Length = 0) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_PathNullOrEmpty))
+ Throw New ArgumentException(SR.Argument_PathNullOrEmpty)
End If
End Sub
Return Nothing
Case Else
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "CallType"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "CallType"))
End Select
End Function
If service Is GetType(NumberFormatInfo) Then
Return nfi
End If
- Throw New ArgumentException(GetResourceString(SR.InternalError_VisualBasicRuntime))
+ Throw New ArgumentException(SR.InternalError_VisualBasicRuntime)
End Function
End Class
SyncLock m_SyncObject
If Not m_LastUsedYesNoCulture Is ci Then
m_LastUsedYesNoCulture = ci
- m_CachedYesNoFormatStyle = GetResourceString(SR.YesNoFormatStyle)
+ m_CachedYesNoFormatStyle = SR.YesNoFormatStyle
End If
Return m_CachedYesNoFormatStyle
End SyncLock
SyncLock m_SyncObject
If Not m_LastUsedOnOffCulture Is ci Then
m_LastUsedOnOffCulture = ci
- m_CachedOnOffFormatStyle = GetResourceString(SR.OnOffFormatStyle)
+ m_CachedOnOffFormatStyle = SR.OnOffFormatStyle
End If
Return m_CachedOnOffFormatStyle
End SyncLock
SyncLock m_SyncObject
If Not m_LastUsedTrueFalseCulture Is ci Then
m_LastUsedTrueFalseCulture = ci
- m_CachedTrueFalseFormatStyle = GetResourceString(SR.TrueFalseFormatStyle)
+ m_CachedTrueFalseFormatStyle = SR.TrueFalseFormatStyle
End If
Return m_CachedTrueFalseFormatStyle
End SyncLock
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValueType2, "SourceArray", "String"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValueType2, "SourceArray", "String"))
End Try
Return Join(StringSource, Delimiter)
End If
If SourceArray.Rank <> 1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_RankEQOne1))
+ Throw New ArgumentException(SR.Format(SR.Argument_RankEQOne1))
End If
Return System.String.Join(Delimiter, SourceArray)
Try
'Validate Parameters
If Count < -1 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_GEMinusOne1, "Count"))
+ Throw New ArgumentException(SR.Format(SR.Argument_GEMinusOne1, "Count"))
End If
If Start <= 0 Then
- Throw New ArgumentException(GetResourceString("Argument_GTZero1", "Start"))
+ Throw New ArgumentException(SR.Format(SR.Argument_GTZero1, "Start"))
End If
If (Expression Is Nothing) OrElse (Start > Expression.Length) Then
Return New String(ChrW(32), Number)
End If
- Throw New ArgumentException(GetResourceString(SR.Argument_GEZero1, "Number"))
+ Throw New ArgumentException(SR.Format(SR.Argument_GEZero1, "Number"))
End Function
Dim SingleChar As Char
If Number < 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Number"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Number"))
End If
If Character Is Nothing Then
- Throw New ArgumentNullException(GetResourceString(SR.Argument_InvalidNullValue1, "Character"))
+ Throw New ArgumentNullException(SR.Format(SR.Argument_InvalidNullValue1, "Character"))
End If
s = TryCast(Character, String)
If s IsNot Nothing Then
If s.Length = 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_LengthGTZero1, "Character"))
+ Throw New ArgumentException(SR.Format(SR.Argument_LengthGTZero1, "Character"))
End If
SingleChar = s.Chars(0)
Else
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Character"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Character"))
End Try
End If
Public Function StrDup(ByVal Number As Integer, ByVal Character As Char) As String
If Number < 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_GEZero1, "Number"))
+ Throw New ArgumentException(SR.Format(SR.Argument_GEZero1, "Number"))
End If
Return New String(Character, Number)
Public Function StrDup(ByVal Number As Integer, ByVal Character As String) As String
If Number < 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_GEZero1, "Number"))
+ Throw New ArgumentException(SR.Format(SR.Argument_GEZero1, "Number"))
End If
If Character Is Nothing OrElse Character.Length = 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_LengthGTZero1, "Character"))
+ Throw New ArgumentException(SR.Format(SR.Argument_LengthGTZero1, "Character"))
End If
Return New String(Character.Chars(0), Number)
If iformat Is Nothing Then
tc = System.Convert.GetTypeCode(Expression)
If tc <> TypeCode.String AndAlso tc <> TypeCode.Boolean Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Expression"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Expression"))
End If
End If
ValidateTriState(GroupDigits)
If NumDigitsAfterDecimal > 99 Then 'Was 255 in VB6, but System.Globalization.NumberFormatInfo.CurrencyDecimalDigits limits this to 99.
- Throw New ArgumentException(GetResourceString(SR.Argument_Range0to99_1, "NumDigitsAfterDecimal"))
+ Throw New ArgumentException(SR.Format(SR.Argument_Range0to99_1, "NumDigitsAfterDecimal"))
End If
If Expression Is Nothing Then
If typ Is GetType(System.String) Then
Expression = CDbl(Expression)
ElseIf Not Symbols.IsNumericType(typ) Then
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(typ), "Currency"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(typ), "Currency"))
End If
ifmt = CType(Expression, IFormattable)
Expression = 0.0
End If
ElseIf Not Symbols.IsNumericType(typ) Then
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(typ), "Currency"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(typ), "Currency"))
End If
ifmt = CType(Expression, IFormattable)
If NumDigitsAfterDecimal = -1 Then
NumDigitsAfterDecimal = nfi.NumberDecimalDigits
ElseIf (NumDigitsAfterDecimal > 99) OrElse (NumDigitsAfterDecimal < -1) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_Range0to99_1, "NumDigitsAfterDecimal"))
+ Throw New ArgumentException(SR.Format(SR.Argument_Range0to99_1, "NumDigitsAfterDecimal"))
End If
If GroupDigits = TriState.UseDefault Then
If typ Is GetType(System.String) Then
Expression = CDbl(Expression)
ElseIf Not Symbols.IsNumericType(typ) Then
- Throw New InvalidCastException(GetResourceString(SR.InvalidCast_FromTo, VBFriendlyName(typ), "numeric"))
+ Throw New InvalidCastException(SR.Format(SR.InvalidCast_FromTo, VBFriendlyName(typ), "numeric"))
End If
ifmt = CType(Expression, IFormattable)
'============================================================================
Public Function GetChar(ByVal [str] As String, ByVal Index As Integer) As Char
If [str] Is Nothing Then
- Throw New ArgumentException(GetResourceString(SR.Argument_LengthGTZero1, "String"))
+ Throw New ArgumentException(SR.Format(SR.Argument_LengthGTZero1, "String"))
ElseIf (Index < 1) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_GEOne1, "Index"))
+ Throw New ArgumentException(SR.Format(SR.Argument_GEOne1, "Index"))
ElseIf (Index > [str].Length) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_IndexLELength2, "Index", "String"))
+ Throw New ArgumentException(SR.Format(SR.Argument_IndexLELength2, "Index", "String"))
Else
Return [str].Chars(Index - 1)
End If
ElseIf ([Compare] = CompareMethod.Text) Then
Return Operators.CompareString(String1, String2, True)
Else
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidValue1, "Compare"))
+ Throw New ArgumentException(SR.Format(SR.Argument_InvalidValue1, "Compare"))
End If
Catch ex As Exception
Throw ex
Catch ex As System.Threading.ThreadAbortException
Throw ex
Catch
- Throw New ArgumentException(GetResourceString(SR.Argument_LCIDNotSupported1, CStr(LocaleID)))
+ Throw New ArgumentException(SR.Format(SR.Argument_LCIDNotSupported1, CStr(LocaleID)))
End Try
End If
If (Conversion And Not (VbStrConv.Uppercase Or VbStrConv.Lowercase Or VbStrConv.Wide Or VbStrConv.Narrow _
Or VbStrConv.Katakana Or VbStrConv.Hiragana Or VbStrConv.SimplifiedChinese Or VbStrConv.TraditionalChinese _
Or VbStrConv.LinguisticCasing)) <> 0 Then
- Throw New ArgumentException(GetResourceString(SR.Argument_InvalidVbStrConv))
+ Throw New ArgumentException(SR.Argument_InvalidVbStrConv)
End If
'*** VbStrConv.SimplifiedChinese/VbStrConv.TraditionalChinese handling
Case 0
'Flags not used
Case (VbStrConv.SimplifiedChinese + VbStrConv.TraditionalChinese)
- Throw New ArgumentException(GetResourceString(SR.Argument_StrConvSCandTC))
+ Throw New ArgumentException(SR.Argument_StrConvSCandTC)
Case VbStrConv.SimplifiedChinese
If IsValidCodePage(CODEPAGE_SIMPLIFIED_CHINESE) AndAlso IsValidCodePage(CODEPAGE_TRADITIONAL_CHINESE) Then
dwMapFlags = dwMapFlags Or NativeTypes.LCMAP_SIMPLIFIED_CHINESE
Else
- Throw New ArgumentException(GetResourceString(SR.Argument_SCNotSupported))
+ Throw New ArgumentException(SR.Argument_SCNotSupported)
End If
Case VbStrConv.TraditionalChinese
If IsValidCodePage(CODEPAGE_SIMPLIFIED_CHINESE) AndAlso IsValidCodePage(CODEPAGE_TRADITIONAL_CHINESE) Then
dwMapFlags = dwMapFlags Or NativeTypes.LCMAP_TRADITIONAL_CHINESE
Else
- Throw New ArgumentException(GetResourceString(SR.Argument_TCNotSupported))
+ Throw New ArgumentException(SR.Argument_TCNotSupported)
End If
End Select
Case VbStrConv.None
'No conversion
If (Conversion And VbStrConv.LinguisticCasing) <> 0 Then
- Throw New ArgumentException(GetResourceString(SR.LinguisticRequirements))
+ Throw New ArgumentException(SR.LinguisticRequirements)
End If
Case (VbStrConv.Uppercase Or VbStrConv.Lowercase) ' VbStrConv.ProperCase is special: see below
If ((Conversion And (VbStrConv.Katakana + VbStrConv.Hiragana)) <> 0) Then
If (langid <> LANG_JAPANESE) OrElse (Not ValidLCID(LocaleID)) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_JPNNotSupported))
+ Throw New ArgumentException(SR.Argument_JPNNotSupported)
Else
'Locale is ok
End If
(langid = LANG_KOREAN) OrElse
(langid = LANG_CHINESE) Then
If Not ValidLCID(LocaleID) Then
- Throw New ArgumentException(GetResourceString(SR.Argument_LocalNotSupported))
+ Throw New ArgumentException(SR.Argument_LocalNotSupported)
End If
Else
- Throw New ArgumentException(GetResourceString(SR.Argument_WideNarrowNotApplicable))
+ Throw New ArgumentException(SR.Argument_WideNarrowNotApplicable)
End If
End If
Select Case (Conversion And (VbStrConv.Wide Or VbStrConv.Narrow))
Case VbStrConv.None
Case VbStrConv.Wide Or VbStrConv.Narrow ' VbStrConv.Wide+VbStrConv.Narrow is reserved
- Throw New ArgumentException(GetResourceString(SR.Argument_IllegalWideNarrow))
+ Throw New ArgumentException(SR.Argument_IllegalWideNarrow)
Case VbStrConv.Wide ' VbStrConv.Wide
dwMapFlags = dwMapFlags Or NativeTypes.LCMAP_FULLWIDTH
Case VbStrConv.Narrow ' VbStrConv.Narrow
Select Case (Conversion And (VbStrConv.Katakana Or VbStrConv.Hiragana))
Case VbStrConv.None
Case (VbStrConv.Katakana Or VbStrConv.Hiragana) ' VbStrConv.Katakana+VbStrConv.Hiragana is reserved
- Throw New ArgumentException(GetResourceString(SR.Argument_IllegalKataHira))
+ Throw New ArgumentException(SR.Argument_IllegalKataHira)
Case VbStrConv.Katakana ' VbStrConv.Katakana
dwMapFlags = dwMapFlags Or NativeTypes.LCMAP_KATAKANA
Case VbStrConv.Hiragana ' VbStrConv.Hiragana
AssertExtensions.Throws<ArgumentOutOfRangeException>("sourceIndex", "srcIndex", () => Utils.CopyArray(array1, array2));
AssertExtensions.Throws<ArgumentOutOfRangeException>("sourceIndex", "srcIndex", () => Utils.CopyArray(array2, array1));
}
+
+ [Fact]
+ public void GetResourceString()
+ {
+ if (System.Threading.Thread.CurrentThread.CurrentCulture.Name == "en-US")
+ {
+ Assert.Equal("Argument '42' is not a valid value.", Utils.GetResourceString("Argument_InvalidValue1", "42"));
+ Assert.Equal("Argument '42' is not a valid value.", Utils.GetResourceString(ResourceKey: "Argument_InvalidValue1", Args: new[] { "42" }));
+ Assert.Equal("Application-defined or object-defined error.", Utils.GetResourceString("UnrecognizedResourceKey"));
+ }
+ }
}
}