Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio WinForms designer unable to display forms exported to C# in VS #3374

Open
karpiyon opened this issue Jan 19, 2025 · 1 comment
Labels

Comments

@karpiyon
Copy link

Hi,
I am starting a new thread after reading this one.

VS does not present teh exported code forms properly in any of the forms I exported.
I am trying to decompile the following file as show in RH:

Image
trying to open in VS I get:

Image

An example of this 'About' form which VS cannot show is composed of fclsAbout.cs & fclsAbout.resx
This is the code generated using ILspy:

fclsAbout.cs

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using Microsoft.VisualBasic.CompilerServices;

namespace MissionCommander
{
	// Token: 0x02000012 RID: 18
	[DesignerGenerated]
	public partial class fclsAbout : Form
	{
		// Token: 0x060000E0 RID: 224 RVA: 0x00008525 File Offset: 0x00006725
		public fclsAbout()
		{
			base.Load += this.fclsAbout_Load;
			this.InitializeComponent();
		}

		// Token: 0x17000035 RID: 53
		// (get) Token: 0x060000E3 RID: 227 RVA: 0x000089D3 File Offset: 0x00006BD3
		// (set) Token: 0x060000E4 RID: 228 RVA: 0x000089DB File Offset: 0x00006BDB
		internal virtual Button btnClose
		{
			get; [MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		// Token: 0x17000036 RID: 54
		// (get) Token: 0x060000E5 RID: 229 RVA: 0x000089E4 File Offset: 0x00006BE4
		// (set) Token: 0x060000E6 RID: 230 RVA: 0x000089EC File Offset: 0x00006BEC
		internal virtual GroupBox grpInfo
		{
			get; [MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		// Token: 0x17000037 RID: 55
		// (get) Token: 0x060000E7 RID: 231 RVA: 0x000089F5 File Offset: 0x00006BF5
		// (set) Token: 0x060000E8 RID: 232 RVA: 0x000089FD File Offset: 0x00006BFD
		internal virtual Label lblVer
		{
			get; [MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		// Token: 0x17000038 RID: 56
		// (get) Token: 0x060000E9 RID: 233 RVA: 0x00008A06 File Offset: 0x00006C06
		// (set) Token: 0x060000EA RID: 234 RVA: 0x00008A0E File Offset: 0x00006C0E
		internal virtual Label lblMC
		{
			get; [MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		// Token: 0x17000039 RID: 57
		// (get) Token: 0x060000EB RID: 235 RVA: 0x00008A17 File Offset: 0x00006C17
		// (set) Token: 0x060000EC RID: 236 RVA: 0x00008A20 File Offset: 0x00006C20
		internal virtual LinkLabel lnkWDP
		{
			[CompilerGenerated]
			get
			{
				return this._lnkWDP;
			}
			[CompilerGenerated]
			[MethodImpl(MethodImplOptions.Synchronized)]
			set
			{
				LinkLabelLinkClickedEventHandler linkLabelLinkClickedEventHandler = new LinkLabelLinkClickedEventHandler(this.lnkWDP_LinkClicked);
				LinkLabel linkLabel = this._lnkWDP;
				if (linkLabel != null)
				{
					linkLabel.LinkClicked -= linkLabelLinkClickedEventHandler;
				}
				this._lnkWDP = value;
				linkLabel = this._lnkWDP;
				if (linkLabel != null)
				{
					linkLabel.LinkClicked += linkLabelLinkClickedEventHandler;
				}
			}
		}

		// Token: 0x1700003A RID: 58
		// (get) Token: 0x060000ED RID: 237 RVA: 0x00008A63 File Offset: 0x00006C63
		// (set) Token: 0x060000EE RID: 238 RVA: 0x00008A6B File Offset: 0x00006C6B
		internal virtual Label lblCreated
		{
			get; [MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		// Token: 0x060000EF RID: 239 RVA: 0x00008A74 File Offset: 0x00006C74
		private void fclsAbout_Load(object sender, EventArgs e)
		{
			this.lblVer.Text = "Version: " + this.Version;
		}

		// Token: 0x060000F0 RID: 240 RVA: 0x00008A91 File Offset: 0x00006C91
		private void lnkWDP_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			Process.Start("http://www.weapondeliveryplanner.nl");
			base.DialogResult = DialogResult.OK;
		}

		// Token: 0x04000076 RID: 118
		public string Version;
	}
}

and fclsAbout.resx:

<?xml version="1.0" encoding="utf-8"?>
<root>
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
       .....
</value>
  </data>
</root>

Can this be fixed?

@karpiyon karpiyon added the Bug label Jan 19, 2025
@siegfriedpammer
Copy link
Member

This looks like the original code was written in VB.NET using WithEvents declarations. The problem is described in detail in the issue you are referencing.

To answer your question: I don't think this can be fixed unless someone adds a transformation step that handles these patterns explicitly. It seems looks like a lot of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants