看来已经正常运行,是其他的问题导致的
System.TypeInitializationException: “xx.2.NS006.c000052”的类型初始值设定项引发异常。 ---> System.FormatException: Base-64 字符串中的无效字符。
在 System.Convert.FromBase64String(String s)
在 xx.2.NS001.c000002.m000001(Int32 p0)
在 xx.2.NS006.c000052..cctor()
--- 内部异常堆栈跟踪的结尾 ---
在 xx.2.NS006.c000052.m000002()
在 xx.2.NS006.c000055.GetLicense(LicenseContext context, Type type, Object instance, Boolean allowExceptions)
在 System.ComponentModel.LicenseManager.ValidateInternalRecursive(LicenseContext context, Type type, Object instance, Boolean allowExceptions, License& license, String& licenseKey)
在 System.ComponentModel.LicenseManager.ValidateInternal(Type type, Object instance, Boolean allowExceptions, License& license)
在 System.ComponentModel.LicenseManager.Validate(Type type, Object instance)
在 xx.Barcodes.Pdf417..ctor()
看来是读取license出错的,把这部分去掉就行了
找到xx.2.NS006.c000055.GetLicense(LicenseContext context, Type type, Object instance, Boolean allowExceptions)
只要让他直接返回 license就可以了
经过分析
L_0056: newobj instance void xx.2.NS006.c000054::.ctor()
L_005b: stloc.s license
L_005d: leave L_01ba
L_0062: ldarg.1
L_0063: ldarg.2
L_0064: ldloc.0
L_0065: callvirt instance void [System]System.ComponentModel.LicenseContext::SetSavedLicenseKey(class [mscorlib]System.Type, string)
L_006a: newobj instance void xx.2.NS006.c000053::.ctor()
L_006f: stloc.s license
经过分系 xx.2.NS006.c000054:
xx.2.NS006.c000053: 两个类一样
将GetLicense 函数此部分IL修改为
.method public hidebysig virtual instance class [System]System.ComponentModel.License
GetLicense(class [System]System.ComponentModel.LicenseContext context,
class [mscorlib]System.Type 'type',
object 'instance',
bool allowExceptions) cil managed
{
// Code size 451 (0x1c3)
.maxstack 48
.locals init (string V_0,
string V_1,
string V_2,
class [System]System.ComponentModel.LicenseException V_3,
class [System]System.ComponentModel.License V_4,
valuetype xx.2.NS006'.enum000051 V_5,
valuetype xx.2.NS006'.enum000051 V_6)
IL_0001: newobj instance void xx.2.NS006'.c000054::.ctor()
IL_0002: stloc.s V_4
IL_0003: ldloc.s V_4
IL_0004: ret
} // end of method c000055::GetLicense
出现了新的异常
System.FormatException: Base-64 字符串中的无效字符。
在 System.Convert.FromBase64String(String s)
在 xx.2.NS001.c000002.m000001(Int32 p0)
在 xx.2.NS006.c000054.get_LicenseKey()
在 System.ComponentModel.LicenseManager.ValidateInternalRecursive(LicenseContext context, Type type, Object instance, Boolean allowExceptions, License& license, String& licenseKey)
在 System.ComponentModel.LicenseManager.ValidateInternal(Type type, Object instance, Boolean allowExceptions, License& license)
在 System.ComponentModel.LicenseManager.Validate(Type type, Object instance)
在 xx.Barcodes.Pdf417..ctor()
找到 c000054
.method public hidebysig specialname virtual instance string get_LicenseKey() cil managed
{
.maxstack 8
L_0000: ldc.i4 0x1079e
L_0005: br.s L_0008
L_0007: ret
L_0008: br.s L_000c
L_000a: br.s L_0007
L_000c: br.s L_0010
L_000e: br.s L_000a
L_0010: call string xx.2.NS001.c000002::m000001(int32)
L_0015: br.s L_000e
}
修改IL代码为
.maxstack 8
.locals init (
[0] string CS$1$0000)
L_0000: nop
L_0001: ldstr "Jetboy"
L_0006: stloc.0
L_0007: br.s L_0009
L_0009: ldloc.0
L_000a: ret