维护没有源代码,float改成double

	float f= 931340.31f;
	Console.WriteLine(f.ToString("#,###,##0.00"));

返回 931,340.30 ,float 10w以上2位小数,就会掉精度,改成double,没有源代码  

ilasm和ildasm要相同Framework才行 framework2反编译的,不能用1.1编译通过

1.1的代码 ,没装vs2003 ,ildasm 在 sc_vs.net_2003_enar_cd2.iso

\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin 下,单独解压可以用

Model.Common,Data.Common,WebHr,Web.PageControl ,找到所有BasicSalary 关键字 float32改成float64 (这个double )

附近Null2Float改成Null2Double,NullFloat改成NullDouble 

 

Model.Common 缺NullDouble 方法

在NullFloat附近添加

    .method public hidebysig static float64 
            NullDouble(object 'value') cil managed
    {
      // 代码大小       16 (0x10)
      .maxstack  2
      IL_0000:  ldarg.0
      IL_0001:  ldc.r8     0.0
      IL_000a:  call       float64 Penseesoft.Web.Model.Utility.NullUtil::NullDouble(object,
                                                                                     float64)
      IL_000f:  ret
    } // end of method NullUtil::NullDouble

    .method public hidebysig static float64 
            NullDouble(object 'value',
                       float64 defaultValue) cil managed
    {
      // 代码大小       38 (0x26)
      .maxstack  1
      .locals init (float64 V_0)
      IL_0000:  ldarg.0
      IL_0001:  call       bool Penseesoft.Web.Model.Utility.NullUtil::IsNullObject(object)
      IL_0006:  brfalse.s  IL_000c

      IL_0008:  ldarg.1
      IL_0009:  stloc.0
      IL_000a:  br.s       IL_0024

      .try
      {
        IL_000c:  ldarg.0
        IL_000d:  call       float64 [mscorlib]System.Convert::ToDouble(object)
        IL_0012:  stloc.0
        IL_0013:  ldloc.0
        IL_0014:  call       bool [mscorlib]System.Double::IsNaN(float64)
        IL_0019:  brfalse.s  IL_001d

        IL_001b:  ldarg.1
        IL_001c:  stloc.0
        IL_001d:  leave.s    IL_0024

      }  // end .try
      catch [mscorlib]System.Exception 
      {
        IL_001f:  pop
        IL_0020:  ldarg.1
        IL_0021:  stloc.0
        IL_0022:  leave.s    IL_0024

      }  // end handler
      IL_0024:  ldloc.0
      IL_0025:  ret
    } // end of method NullUtil::NullDouble

  

 

callvirt instance float32 [Model.Common]Penseesoft.Web.Model.StaffInfo::get_BasicSalary()
stloc.s V_9
 ldloca.s V_9
 ldstr "#,##0.00"
call instance string [mscorlib]System.Single::ToString(string)

另外.net调用过程,压堆栈,会压一个变量 V_9 

变量申明在 函数申明后

.locals init (int32 V_0,
class [System.Web]System.Web.UI.WebControls.Panel V_1,
class [Model.Common]Penseesoft.Web.Model.StaffInfo V_2,
class [Model.Payroll]Penseesoft.Web.Model.Payroll.PayTermsInfo V_3,
int32 V_4,
class [System.Data]System.Data.DataRow V_5,
class [System.Web]System.Web.UI.WebControls.Panel[] V_6,
int32 V_7,
valuetype [mscorlib]System.DateTime V_8,
float32 V_9,
float64 V_10)

如果本来V_9 是float32,方法改成double,如果不新增float64 V_10 ,改成V_10的话,float, ilasm可以编译过,运行会出一个很大数字。

ilspy + Reflexil ,有Verfiy菜单项可以用下,看编译的dll是否有问题 

 

bat文件

 

set ilasm=%windir%\Microsoft.NET\Framework\v1.1.4322\ilasm /dll /QUIET

%ilasm% Web.PageControls.il /res:Web.PageControls.res
%ilasm% WebHr.il /res:WebHr.res
%ilasm% Data.Common.il /res:Data.Common.res
%ilasm% Model.Common.il /res:Model.Common.res

pause

posted on 2016-07-06 16:20  聪明的大熊  阅读(615)  评论(0编辑  收藏  举报