chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Using the following:

_expectedWorkingDays = 0;

Mock mockFILibrary = MockManager.MockAll(typeof(FILibrary));

mockFILibrary.ExpectAndReturn("cmCreateDateRuleDays", false, 1).Args(new object[] {_expectedRuleName, _expectedRuleDescription, _expectedDayShift, false, _expectedShiftConvention});


I get the following error in NUnit:

Rbsfm.Common.CAFWrapper2.BondWrapperTest.AddDateRuleTest_WorkingDaysNotGreaterThanZero : Rbsfm.Common.CAFWrapper2.CAFException : error adding bond library date rule Test Rule Name
  ----> System.InvalidProgramException : Common Language Runtime detected an invalid program.


I have a trace file from which I pulled the following:


Rbsfm.Common.CAFWrapper2.BondWrapper instance void AddDateRule(class System.String,class System.String,int32,int32,class System.String)
IL_0 = ldarg.0
IL_1 = ldstr 0x70004FDC
IL_2 = ldstr 0x70005068
IL_3 = call 0x0A000145
IL_4 = brfalse 0x000000A1
IL_5 = ldarg.0
IL_6 = ldstr 0x70004FDC
IL_7 = ldstr 0x70005068
IL_8 = ldarg.1
IL_9 = ldarg.2
IL_10 = ldarg.3
IL_11 = box 0x01000025
IL_12 = ldarg.s 0x04
IL_13 = box 0x01000025
IL_14 = ldarg.s 0x05
IL_15 = call 0x0A00014A
IL_16 = dup
IL_17 = ldstr 0x70004FDC
IL_18 = ldstr 0x70005068
IL_19 = ldc.i4.0
IL_20 = call 0x0A000147
IL_21 = starg.s 0x01
IL_22 = ldstr 0x70004FDC
IL_23 = ldstr 0x70005068
IL_24 = ldc.i4.1
IL_25 = call 0x0A000147
IL_26 = starg.s 0x02
IL_27 = ldstr 0x70004FDC
IL_28 = ldstr 0x70005068
IL_29 = ldc.i4.2
IL_30 = call 0x0A000147
IL_31 = unbox 0x01000025
IL_32 = ldind.i4
IL_33 = starg.s 0x03
IL_34 = ldstr 0x70004FDC
IL_35 = ldstr 0x70005068
IL_36 = ldc.i4.3
IL_37 = call 0x0A000147
IL_38 = unbox 0x01000025
IL_39 = ldind.i4
IL_40 = starg.s 0x04
IL_41 = ldstr 0x70004FDC
IL_42 = ldstr 0x70005068
IL_43 = ldc.i4.4
IL_44 = call 0x0A000147
IL_45 = starg.s 0x05
IL_46 = ldstr 0x70004FDC
IL_47 = ldstr 0x70005068
IL_48 = call 0x0A000148
IL_49 = isinst 0x01000049
IL_50 = brtrue.s 0x02
IL_51 = pop
IL_52 = ret
IL_53 = pop
 nop
 nop
*INFO: SMALL EH clause TryOffset '0x00000000' HandlerOffset '0x00000021' Changed to: TryOffset '0x000000B8' HandlerOffset: '0x000000D9'
 
CAFServer.FILibrary bool cmCreateDateRuleDays(class System.String,class System.String,int32,bool,class System.String)
IL_0 = ldnull
IL_1 = ldstr 0x70000001
IL_2 = ldstr 0x70000029
IL_3 = call 0x0A000048
IL_4 = brfalse 0x000000A5
IL_5 = ldnull
IL_6 = ldstr 0x70000001
IL_7 = ldstr 0x70000029
IL_8 = ldarg.0
IL_9 = ldarg.1
IL_10 = ldarg.2
IL_11 = box 0x01000025
IL_12 = ldarg.3
IL_13 = box 0x01000028
IL_14 = ldarg.s 0x04
IL_15 = call 0x0A00004C
IL_16 = dup
IL_17 = ldstr 0x70000001
IL_18 = ldstr 0x70000029
IL_19 = ldc.i4.0
IL_20 = call 0x0A00004A
IL_21 = starg.s 0x00
IL_22 = ldstr 0x70000001
IL_23 = ldstr 0x70000029
IL_24 = ldc.i4.1
IL_25 = call 0x0A00004A
IL_26 = starg.s 0x01
IL_27 = ldstr 0x70000001
IL_28 = ldstr 0x70000029
IL_29 = ldc.i4.2
IL_30 = call 0x0A00004A
IL_31 = unbox 0x01000025
IL_32 = ldind.i4
IL_33 = starg.s 0x02
IL_34 = ldstr 0x70000001
IL_35 = ldstr 0x70000029
IL_36 = ldc.i4.3
IL_37 = call 0x0A00004A
IL_38 = unbox 0x01000028
IL_39 = ldind.i1
IL_40 = starg.s 0x03
IL_41 = ldstr 0x70000001
IL_42 = ldstr 0x70000029
IL_43 = ldc.i4.4
IL_44 = call 0x0A00004A
IL_45 = starg.s 0x04
IL_46 = ldstr 0x70000001
IL_47 = ldstr 0x70000029
IL_48 = call 0x0A00004B
IL_49 = isinst 0x01000040
IL_50 = brtrue.s 0x07
IL_51 = unbox 0x01000028
IL_52 = ldind.i1
IL_53 = ret
IL_54 = pop
 nop
 nop
*INFO: FAT EH clause TryOffset '0x00000077' HandlerOffset '0x00000083' Changed to: TryOffset '0x00000133' HandlerOffset: '0x0000013F'
 *INFO: FAT EH clause TryOffset '0x00000056' HandlerOffset '0x00000099' Changed to: TryOffset '0x00000112' HandlerOffset: '0x00000155'
 *INFO: FAT EH clause TryOffset '0x0000004C' HandlerOffset '0x000000AF' Changed to: TryOffset '0x00000108' HandlerOffset: '0x0000016B'
 *INFO: FAT EH clause TryOffset '0x00000042' HandlerOffset '0x000000C5' Changed to: TryOffset '0x000000FE' HandlerOffset: '0x00000181'
 *INFO: FAT EH clause TryOffset '0x00000038' HandlerOffset '0x000000DB' Changed to: TryOffset '0x000000F4' HandlerOffset: '0x00000197'
 *INFO: FAT EH clause TryOffset '0x0000002E' HandlerOffset '0x000000F1' Changed to: TryOffset '0x000000EA' HandlerOffset: '0x000001AD'
 *INFO: FAT EH clause TryOffset '0x00000023' HandlerOffset '0x00000107' Changed to: TryOffset '0x000000DF' HandlerOffset: '0x000001C3'
 *INFO: FAT EH clause TryOffset '0x00000153' HandlerOffset '0x00000166' Changed to: TryOffset '0x0000020F' HandlerOffset: '0x00000222'
 *INFO: FAT EH clause TryOffset '0x00000149' HandlerOffset '0x0000017C' Changed to: TryOffset '0x00000205' HandlerOffset: '0x00000238'
 *INFO: FAT EH clause TryOffset '0x0000013F' HandlerOffset '0x00000192' Changed to: TryOffset '0x000001FB' HandlerOffset: '0x0000024E'
 *INFO: FAT EH clause TryOffset '0x00000135' HandlerOffset '0x000001A8' Changed to: TryOffset '0x000001F1' HandlerOffset: '0x00000264'
 *INFO: FAT EH clause TryOffset '0x0000012B' HandlerOffset '0x000001BE' Changed to: TryOffset '0x000001E7' HandlerOffset: '0x0000027A'
 *INFO: FAT EH clause TryOffset '0x00000010' HandlerOffset '0x000001E2' Changed to: TryOffset '0x000000CC' HandlerOffset: '0x0000029E'
 *INFO: FAT EH 'FILTER' offset '0x00000239' to '0x000002F5'
*INFO: FAT EH clause TryOffset '0x00000220' HandlerOffset '0x00000248' Changed to: TryOffset '0x000002DC' HandlerOffset: '0x00000304'
 *INFO: FAT EH clause TryOffset '0x00000220' HandlerOffset '0x00000252' Changed to: TryOffset '0x000002DC' HandlerOffset: '0x0000030E'
 *INFO: FAT EH 'FILTER' offset '0x000001FB' to '0x000002B7'
*INFO: FAT EH clause TryOffset '0x00000008' HandlerOffset '0x00000211' Changed to: TryOffset '0x000000C4' HandlerOffset: '0x000002CD'
 *INFO: FAT EH 'FILTER' offset '0x0000029B' to '0x00000357'
*INFO: FAT EH clause TryOffset '0x00000284' HandlerOffset '0x000002AA' Changed to: TryOffset '0x00000340' HandlerOffset: '0x00000366'
 *INFO: FAT EH clause TryOffset '0x00000284' HandlerOffset '0x000002B4' Changed to: TryOffset '0x00000340' HandlerOffset: '0x00000370'
 *INFO: FAT EH 'FILTER' offset '0x0000025F' to '0x0000031B'
*INFO: FAT EH clause TryOffset '0x00000008' HandlerOffset '0x00000275' Changed to: TryOffset '0x000000C4' HandlerOffset: '0x00000331'
 *INFO: FAT EH 'FILTER' offset '0x000002FD' to '0x000003B9'
*INFO: FAT EH clause TryOffset '0x000002E6' HandlerOffset '0x0000030C' Changed to: TryOffset '0x000003A2' HandlerOffset: '0x000003C8'
 *INFO: FAT EH clause TryOffset '0x000002E6' HandlerOffset '0x00000316' Changed to: TryOffset '0x000003A2' HandlerOffset: '0x000003D2'
 *INFO: FAT EH 'FILTER' offset '0x000002C1' to '0x0000037D'
*INFO: FAT EH clause TryOffset '0x00000008' HandlerOffset '0x000002D7' Changed to: TryOffset '0x000000C4' HandlerOffset: '0x00000393'
 *INFO: FAT EH 'FILTER' offset '0x00000357' to '0x00000413'
*INFO: FAT EH clause TryOffset '0x00000346' HandlerOffset '0x00000366' Changed to: TryOffset '0x00000402' HandlerOffset: '0x00000422'
 *INFO: FAT EH clause TryOffset '0x00000346' HandlerOffset '0x00000370' Changed to: TryOffset '0x00000402' HandlerOffset: '0x0000042C'
 *INFO: FAT EH 'FILTER' offset '0x00000020' to '0x000000DC'
*INFO: FAT EH clause TryOffset '0x00000008' HandlerOffset '0x00000337' Changed to: TryOffset '0x000000C4' HandlerOffset: '0x000003F3'
 
Rbsfm.Common.CAFWrapper2.CAFException instance void .ctor(class System.String,class S)
IL_0 = ldarg.0
IL_1 = ldstr 0x70005080
IL_2 = ldstr 0x7000505C
IL_3 = call 0x0A000145
IL_4 = brfalse.s 0x50
IL_5 = ldarg.0
IL_6 = ldstr 0x70005080
IL_7 = ldstr 0x7000505C
IL_8 = ldarg.1
IL_9 = ldarg.2
IL_10 = call 0x0A00014B
IL_11 = dup
IL_12 = ldstr 0x70005080
IL_13 = ldstr 0x7000505C
IL_14 = ldc.i4.0
IL_15 = call 0x0A000147
IL_16 = starg.s 0x01
IL_17 = ldstr 0x70005080
IL_18 = ldstr 0x7000505C
IL_19 = ldc.i4.1
IL_20 = call 0x0A00014
asked by c0d3-m0nk3y (8.7k points)

4 Answers

0 votes
Hi,
First, thanks for the detailed output.
We will have to check this out.

:idea: Just a tip. It is better to write:
mockFILibrary.ExpectAndReturn("cmCreateDateRuleDays", false, 1).Args(_expectedRuleName, _expectedRuleDescription, _expectedDayShift, false, _expectedShiftConvention); 


Just to be sure:

cmCreateDateRuleDays is static,
its signiture is (string,string,int,bool,string)
and it returns bool.

If this is true, I think that the problem is in one of the complex try/catch clauses that you have in this method. We will try to reproduce it.
Could you post the try/catch structure (i.e just the try/catch/finally parts of the code) of the cmCreateDateRuleDays method?
answered by richard (3.9k points)
0 votes
The component isn't code I work on directly so I had to extract the code using Net Reflector.

As far as I know the assembly is actually a managed C++ assembly but I could only extract to C# (or VB/Delphi/MSIL per Net Reflector).

The try..catch blocks are nested to multiple levels.

[return: MarshalAs(UnmanagedType.U1)]
public static unsafe bool cmCreateDateRuleDays(string strDateRuleId, string strDescription, int nDayShift, [MarshalAs(UnmanagedType.U1)] bool bIsWorkingDays, string strRollConvention)
{
      uint num1;
      bool flag1;
      int num2 = stackalloc byte[__CxxQueryExceptionSize()];
      try
      {
            FVar var12;
            FVar.__ctor((FVar* modopt(IsConstModifier) modopt(IsConstModifier)) &var12);
            try
            {
                  if (Log.GetStatus())
                  {
                        CPPProxy proxy1;
                        CPPProxy.__ctor((CPPProxy* modopt(IsConstModifier) modopt(IsConstModifier)) &proxy1);
                        try
                        {
                              FVar var11;
                              FVar* varPtr6 = CAFServer.CafFVarTranslation.ConvertToFVar(&var11, strRollConvention);
                              try
                              {
                                    FVar var10;
                                    int num7 = FVar.__ctor((FVar* modopt(IsConstModifier) modopt(IsConstModifier)) &var10, bIsWorkingDays);
                                    try
                                    {
                                          FVar var9;
                                          int num6 = FVar.__ctor((FVar* modopt(IsConstModifier) modopt(IsConstModifier)) &var9, nDayShift);
                                          try
                                          {
                                                FVar var8;
                                                FVar* varPtr5 = CAFServer.CafFVarTranslation.ConvertToFVar(&var8, strDescription);
                                                try
                                                {
                                                      FVar var7;
                                                      FVar* varPtr4 = CAFServer.CafFVarTranslation.ConvertToFVar(&var7, strDateRuleId);
                                                      try
                                                      {
                                                            FVar var6;
                                                            int num5 = CPPProxy.Call((CPPProxy* modopt(IsConstModifier) modopt(IsConstModifier)) &proxy1, &var6, CPPProxy.lookup((CPPProxy modopt(IsConstModifier)* modopt(IsConstModifier) modopt(IsConstModifier)) &proxy1, &??_C@_0BF@ODFBCGDN@cmCreateDateRuleDays?$AA@), (FVar modopt(IsConstModifier)* modopt(IsCXXReferenceModifier)) varPtr4, (FVar modopt(IsConstModifier)* modopt(IsCXXReferenceModifier)) varPtr5, (FVar modopt(IsConstModifier)* modopt(IsCXXReferenceModifier)) num6, (FVar modopt(IsConstModifier)* modopt(IsCXXReferenceModifier)) num7, (FVar modopt(IsConstModifier)* modopt(IsCXXReferenceModifier)) varPtr6);
                                                            try
                                                            {
                                                                  FVar.=((FVar* modopt(IsConstModifier) modopt(IsConstModifier)) &var12, (FVar modopt(IsConstModifier)* modopt(IsCXXReferenceModifier)) num5);
                                                            }
                                                            fault
              &nbsp
answered by c0d3m0nk3y (140 points)
0 votes
Hi,
I have tried to replicate this bug, both on .NET 1.1 and .NET 2.0 and they both work.
Can you try the code with the latest beta version and tell me if there is still a problem. If there is, could it be possible to recieve the problematic dll so I can test it.
I will send you an e-mail if you can send me the dll
answered by scott (32k points)
0 votes
I haven't heard from this lately so I'm closeing the topic, open a new one if this repeats.
answered by scott (32k points)
...