ILSpy icon indicating copy to clipboard operation
ILSpy copied to clipboard

Unnecessary cast

Open CreateAndInject opened this issue 1 year ago • 4 comments

test.zip

FrmApendChargeInfo.InitializeComponent:

			((System.Windows.Forms.Control)(object)this.panelEx1).SuspendLayout();
			((System.ComponentModel.ISupportInitialize)this.tabControl1).BeginInit();
			((System.Windows.Forms.Control)(object)this.tabControl1).SuspendLayout();
			((System.Windows.Forms.Control)(object)this.superTabControlPanel1).SuspendLayout();
			((System.ComponentModel.ISupportInitialize)this.picCardImage).BeginInit();
			((System.Windows.Forms.Control)(object)this.superTabControlPanel4).SuspendLayout();
			((System.ComponentModel.ISupportInitialize)this.picFaceImage).BeginInit();
			((System.Windows.Forms.Control)(object)this.superTabControlPanel3).SuspendLayout();
			((System.ComponentModel.ISupportInitialize)this.picBackImage).BeginInit();
			((System.Windows.Forms.Control)(object)this.superTabControlPanel2).SuspendLayout();
			((System.ComponentModel.ISupportInitialize)this.picFrontImage).BeginInit();
			((System.Windows.Forms.Control)(object)this).SuspendLayout();

See FaceCapture.WndProc also:

  1. virtual => override
  2. System.Runtime.CompilerServices.Unsafe.As

CreateAndInject avatar Jun 15 '23 18:06 CreateAndInject

Do you have the necessary reference assemblies loaded? If they are not loaded, then the decompiler does not know that TabControl is derived from Control, so it has to use an explicit cast instead of an implicit conversion.

dgrunwald avatar Jun 15 '23 19:06 dgrunwald

@dgrunwald @siegfriedpammer Yes, reference assembly is loaded, see test.zip I think this issue is: .exe is .NET 4, and DevComponents.DotNetBar2.dll is .NET 2.0, when we use a control defined in DevComponents.DotNetBar2.dll, ILSpy make mistakes

CreateAndInject avatar Jun 15 '23 19:06 CreateAndInject

If you are decompiling a .NET 2.0 dll, you ideally need .NET 2.0 reference assemblies loaded. The target framework of the overall .exe does not matter in this case.

dgrunwald avatar Aug 11 '23 15:08 dgrunwald

If you are decompiling a .NET 2.0 dll, you ideally need .NET 2.0 reference assemblies loaded. The target framework of the overall .exe does not matter in this case.

No, I'm not decompiling a .NET 2.0 dll, I'm decompiling a .NET 4.0 exe, and this exe references both 2.0 and 4.0 dlls

CreateAndInject avatar Aug 11 '23 16:08 CreateAndInject