Creating a component fails when adding a visual custom class to a form
Posted: Tue Jan 14, 2025 6:26 pm
Hi, Development Team
I'm having problems trying to add a custom visual class (myCheckBox) to a form.
I got the C# source code after asking the AI.
I then created the C# class library project and successfully built a DLL.
I then added the class to the toolbox and successfully added myCheckBox to a form in a C# winform project.
I used ILSpy to get the X# equivalent. And I managed to build the DLL using the foxpro dialect.
When I try to add the X# version of myCheckBox from the toolbox to the form I do see the error:
(The English description in the error message is the translated version via Deepl)
myCheckBox.prg:Line No. 27 :
I'm not sure what's causing the current problem. bug or my code ?
I'm having problems trying to add a custom visual class (myCheckBox) to a form.
I got the C# source code after asking the AI.
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ClassTest
{
public class myCheckBox:CheckBox
{
public myCheckBox()
{
this.TabStop = true;
this.KeyDown += myCheckBox_KeyDown;
}
private void myCheckBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
this.Checked = !this.Checked;
e.Handled = true;
}
else if (e.KeyCode == Keys.Enter)
{
this.Parent.SelectNextControl(this, true, true, true, true);
e.Handled = true;
}
}
}
}
I then added the class to the toolbox and successfully added myCheckBox to a form in a C# winform project.
I used ILSpy to get the X# equivalent. And I managed to build the DLL using the foxpro dialect.
When I try to add the X# version of myCheckBox from the toolbox to the form I do see the error:
(The English description in the error message is the translated version via Deepl)
Code: Select all
Failed to create component “myCheckBox”. The error message is: “Description : Variable does not exist
“Description : Variable does not exist
Subsystem : BASE
GenCode : EG_NOVAR Variable does not exist
FuncSym : MemVarGet
Severity : ES_ERROR
Can Default : False
Can Retry : False
Can Substitute : False
Argument Number : 1
Argument : cName
Arguments : {myCheckBox_KeyDown}
Stack Trace : {myCheckBox_KeyDown}
In XSharp.Error.VOError(UInt32 dwGenCode, String cFuncName, String cArgName, UInt32 iArgNum, Object[] aArgs)
In XSharp.MemVar._Get(String cName)
In XSharp.RT.Functions.__MemVarGet(String cName)
In XSharp.RT.Functions.__VarGet(String cName)
In tq.libs.myCheckBox..ctor() Location E:\ManhattanX\tq\tq.libs\myCheckBox.prg:Line No. 27
in System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
in System.SecurityUtils.SecureConstructorInvoke(Type type, Type[] argTypes, Object[] args, Boolean allowNonPublic, BindingFlags extraFla... ”
Code: Select all
This.KeyDown += myCheckBox_KeyDown