Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将VB.NET exe反编译为C#(dotPeek&;JustDecompile)_C#_Vb.net_Decompiling_Dotpeek - Fatal编程技术网

将VB.NET exe反编译为C#(dotPeek&;JustDecompile)

将VB.NET exe反编译为C#(dotPeek&;JustDecompile),c#,vb.net,decompiling,dotpeek,C#,Vb.net,Decompiling,Dotpeek,所以我有一个从VB.NET构建的程序,但没有源代码,也不可能得到源代码,我需要修改程序,所以我使用dotPeek将其反编译为C,因为我可以用C编写代码,但我从未真正学习过VB.NET(我也尝试过用JustDecompile反编译到VB.NET,但对我来说,它看起来比C更混乱)。但反编译的项目充满了奇怪的代码,我在尝试将C#exe和dll反编译到C#项目时没有看到。它充满了看起来不应该存在的代码(看起来像是幕后代码),如: 这是使用Devexpress版本10,这些代码是因为这些吗?这是正常的还是

所以我有一个从VB.NET构建的程序,但没有源代码,也不可能得到源代码,我需要修改程序,所以我使用dotPeek将其反编译为C,因为我可以用C编写代码,但我从未真正学习过VB.NET(我也尝试过用JustDecompile反编译到VB.NET,但对我来说,它看起来比C更混乱)。但反编译的项目充满了奇怪的代码,我在尝试将C#exe和dll反编译到C#项目时没有看到。它充满了看起来不应该存在的代码(看起来像是幕后代码),如:


这是使用Devexpress版本10,这些代码是因为这些吗?这是正常的还是我可以删除这些代码?

您有一个VB Winform project的调试版本。弱引用内容由调试器使用,不会在发布版本中发出

VB为每个
Dim创建一个属性,其中事件控制名为ControlType
,还有一个方法修饰为
句柄控制名.EventName
。属性设置器包含使句柄事件工作的事件连接代码

例如,按钮及其单击事件

Friend WithEvents按钮1作为按钮
私有子按钮1\u单击(ByVal sender作为对象,ByVal e作为事件参数)处理按钮1。单击
“一些代码
端接头
将导致生成此属性:

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
Friend可重写属性按钮1作为按钮
_
得到
还给我
结束
_
设置(以事件值为按钮的ByVal)
作为EventHandler的Dim处理程序=新的EventHandler(AddressOf Me.Button1\u单击)
将按钮变暗为按钮=Me.\u按钮1
如果(不是按钮什么都不是)那么
RemoveHandler按钮。单击,处理程序
如果结束
Me.\u Button1=带事件值
按钮=我。\ u按钮1
如果(不是按钮什么都不是)那么
添加处理程序按钮。单击,处理程序
如果结束
端集
端属性
您可能还会有许多名称为My_XYZ的类,它们支持VB的应用程序框架


我建议您使用一些控件/事件处理程序创建一个新的VB WinForm项目,然后对其进行反编译,这样您就可以看到反编译器如何从IL中复制锅炉板内容。一旦您了解了模式,它将变得简单得多。

我的答案有助于了解问题并找到自己的解决方案

  • 只需创建您自己的小应用程序,然后将其编译为和 .exe文件
  • 然后使用您使用的反编译器反编译此.exe文件
  • 现在你看到了同样奇怪的代码,你知道你没有把它放在那里

  • 谢谢。

    对别人的代码进行反向工程,然后发布说代码可能违反了T&C的几个关键段落。当然,如果是你的应用程序,那么没什么好担心的。除了它包含你不知道的东西之外?对不起?我不明白你的意思,这个程序是我的,但是程序员再也联系不上了,我需要修改一些程序。这是VB.NET编译器自动生成的代码,用于实现
    with events
    关键字。在C#中没有等价物,不要为下个月制定任何大计划。事实上,代码标记为“调试器非用户代码”这段代码是为调试程序编写的,不是由用户编写的。请注释掉它将创建的代码“成员已存在”错误。它是由调试器生成的,可以安全地注释掉甚至删除。谢谢您还应该提到VB执行此操作的原因-当WithEvents对象设置为另一个对象时,允许复制事件连接。
    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;
      }
    }
    
    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