因此,我有一个从VB.NET构建的程序,但是没有源代码,并且无法获取源代码,我需要修改该程序,因此我可以使用dotPeek和JustDecompile将其反编译为C#,因为我可以在C#,但我从未真正学习过VB.NET(我也尝试过使用JustDecompile将其反编译为VB.NET,但对我来说,它看起来比C#更加混乱)。但是反编译的项目充满了奇怪的代码,当我尝试将C#exe和dll反编译为C#项目时,我看不到这些代码。它充满了看起来不应该存在的代码(看起来像幕后代码),例如:
private static List<WeakReference> __ENCList;
lock (finvendor.__ENCList)
finvendor.__ENCList.Add(new WeakReference((object) this));
[AccessedThroughProperty("controlname")] //for every controls
对于我在C#中找不到的每个控件,它也充满了此类代码:
internal virtual CheckEdit chkNonAktif
{
[DebuggerNonUserCode] get
{
return this._chkNonAktif;
}
[DebuggerNonUserCode, MethodImpl(MethodImplOptions.Synchronized)] set
{
EventHandler eventHandler = new EventHandler(this.chk_CheckedChanged);
if (this._chkNonAktif != null)
this._chkNonAktif.CheckedChanged -= eventHandler;
this._chkNonAktif = value;
if (this._chkNonAktif == null)
return;
this._chkNonAktif.CheckedChanged += eventHandler;
}
}
它使用的是Devexpress版本10,是因为这些代码吗?是正常现象还是我可以删除这些代码?
您具有VB Winform项目的调试版本。弱参考资料由调试器使用,不会在发行版本中发出。
VB为每个属性创建一个属性,对于每个属性,Dim WithEvents ControlName As ControlType
还使用修饰方法Handles ContolName.EventName
。属性设置器包含使Handles Event东西起作用的事件连接代码。
例如,按钮及其单击事件。
Friend WithEvents Button1 As Button
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'some code
End Sub
将导致生成此属性:
Friend Overridable Property Button1 As Button
<CompilerGenerated> _
Get
Return Me._Button1
End Get
<MethodImpl(MethodImplOptions.Synchronized), CompilerGenerated> _
Set(ByVal WithEventsValue As Button)
Dim handler As EventHandler = New EventHandler(AddressOf Me.Button1_Click)
Dim button As Button = Me._Button1
If (Not button Is Nothing) Then
RemoveHandler button.Click, handler
End If
Me._Button1 = WithEventsValue
button = Me._Button1
If (Not button Is Nothing) Then
AddHandler button.Click, handler
End If
End Set
End Property
您可能还会有许多类以My_XYZ的形式命名,它们支持VB的应用程序框架。
我建议您使用几个控件/事件处理程序创建一个新的VB WinForm项目,然后对其进行反编译,以便您可以看到反编译器如何从IL中复制样板文件。一旦知道了模式,它将变得容易得多。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句