Glyn Meek wrote:
> When one gets an error message of the format:
>
> ArgumentException
> Could not find resource assembly
>
> Strings::Mid+0x2e
> Opportunity::isYYYYMMDD+0X29F
> Opportunity::XmlOpportunityProcess+0x260
> PocketSalesManager::LoadTree+0x1ce
> PSMLogo::PSMLogo_Load+0x3ba
> Form::OnLoad+0x15
> Form::_SetVisibleNotify+0x1d
> Control::set_VisibleNotify+0x1f
> Application::Run+0x7
>
> what tools are available in the development/debug environment to tell me
> which source code instruction corresponds to a hex offset such as :
>
> Opportunity::isYYYYMMDD+0X29F
>
If you use ildasm to open the module you will see the offsets on the
left. FOr example let's open Microsoft.VisualBasic.DLL and find the
method Strings::Mid
..method public hidebysig static string Mid(string str,
int32 Start,
int32 Length) cil managed
{
// Code size 119 (0x77)
.maxstack 3
.locals init (int32 V_0,
string V_1)
IL_0000: ldarg.1
IL_0001: ldc.i4.0
IL_0002: bgt.s IL_0018
IL_0004: ldc.i4.s -4
IL_0006: ldstr "Start"
IL_000b: call string
Microsoft.VisualBasic.CompilerServices.Utils::GetResourceString(int32,
string)
IL_0010: newobj instance void
[mscorlib]System.ArgumentException::.ctor(string)
IL_0015: throw
IL_0016: br.s IL_003f
IL_0018: ldarg.2
IL_0019: ldc.i4.0
IL_001a: bge.s IL_0030
IL_001c: ldc.i4.s -3
IL_001e: ldstr "Length"
IL_0023: call string
Microsoft.VisualBasic.CompilerServices.Utils::GetResourceString(int32,
string)
IL_0028: newobj instance void
[mscorlib]System.ArgumentException::.ctor(string)
IL_002d: throw
IL_002e: br.s IL_003f
IL_0030: ldarg.2
IL_0031: ldc.i4.0
IL_0032: beq.s IL_0037
IL_0034: ldarg.0
IL_0035: brtrue.s IL_003f
IL_0037: ldstr ""
IL_003c: stloc.1
IL_003d: br.s IL_0075
IL_003f: ldarg.0
IL_0040: callvirt instance int32 [mscorlib]System.String::get_Length()
IL_0045: stloc.0
IL_0046: ldarg.1
IL_0047: ldloc.0
IL_0048: ble.s IL_0054
IL_004a: ldstr ""
IL_004f: stloc.1
IL_0050: br.s IL_0075
IL_0052: br.s IL_0075
IL_0054: ldarg.1
IL_0055: ldarg.2
IL_0056: add.ovf
IL_0057: ldloc.0
IL_0058: ble.s IL_0068
IL_005a: ldarg.0
IL_005b: ldarg.1
IL_005c: ldc.i4.1
IL_005d: sub.ovf
IL_005e: callvirt instance string
[mscorlib]System.String::Substring(int32)
IL_0063: stloc.1
IL_0064: br.s IL_0075
IL_0066: br.s IL_0075
IL_0068: ldarg.0
IL_0069: ldarg.1
IL_006a: ldc.i4.1
IL_006b: sub.ovf
IL_006c: ldarg.2
IL_006d: callvirt instance string
[mscorlib]System.String::Substring(int32,
int32)
IL_0072: stloc.1
IL_0073: br.s IL_0075
IL_0075: ldloc.1
IL_0076: ret
} // end of method Strings::Mid
As you can see from disassembly, the last instruction before IL_002e is
throw at IL_0028, which throws ArgumentException. In this particlular
case the exception is caused by the Length parameter = 0. In a similar
manner you could look inside your own module. Of course running it under
debugger might be easier, especially if you have debug symbols
|