对于Delphi Prism,我可以肯定的一点是,它是片状的。如果你做了一些改变,并且一次只能在你的程序中使用一行,那么即使程序编译并运行,你总会遇到某种错误。
我所做的只是添加菜单项并添加其事件,现在Delphi Prism编译器每次尝试打开主窗体设计器时都抱怨“对象引用未设置为对象的实例”。我甚至没有看到我的程序的主要winform,但以下信息。我想,如果删除更改,错误就会消失,但事实并非如此。它似乎被困在上面。
Object reference not set to an instance of an object.
Instances of this error (1)
1. Hide Call Stack
at A.d..ctor(String A, j a)
at A.E..ctor(String A, j a)
at A.b.A(F A)
at A.b.Parse(TextReader A)
at System.CodeDom.Compiler.CodeDomProvider.Parse(TextReader codeStream)
at Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomDocDataAdapter.get_CompileUnit()
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
错误消息并不表示它遇到问题的程序或代码的位置或部分,但程序编译并运行完美。现在唯一的事情就是我无法打开主窗口表单设计器来对主winform进行任何更改。
有什么问题? 拜托,帮帮我!!!
更确切地说:我试图添加一个用户定义的对话框窗口,但在这个过程中我最终添加了一个UserControl窗口的新项目作为项目树视图中的一个项目而没有包括resx。从那时起,我的主窗口窗体将不会在设计器中打开,它会显示上面发布的错误。然而,一切都编译和运行。如前所述,我无法在设计器中打开主窗口窗体。
这是main.designer.pas代码:
namespace MillenniaMono.main;
interface
uses
System.Windows.Forms,
System.Drawing;
type
MainForm = partial class
{$REGION Windows Form Designer generated fields}
private
UnitBtn: System.Windows.Forms.Button;
SignalBtn: System.Windows.Forms.Button;
ControlBtn: System.Windows.Forms.Button;
PIDBtn: System.Windows.Forms.Button;
LoggingBtn: System.Windows.Forms.Button;
SystemBtn: System.Windows.Forms.Button;
LoginBtn: System.Windows.Forms.Button;
ScanBtn: System.Windows.Forms.Button;
ShutdownBtn: System.Windows.Forms.Button;
HideBtn: System.Windows.Forms.Button;
CommBtn: System.Windows.Forms.Button;
button5: System.Windows.Forms.Button;
button4: System.Windows.Forms.Button;
button2: System.Windows.Forms.Button;
button1: System.Windows.Forms.Button;
listBox1: System.Windows.Forms.ListBox;
//components: System.ComponentModel.IContainer;
AlarmsBtn: System.Windows.Forms.Button;
DataViewBtn: System.Windows.Forms.Button;
MagiKalBtn: System.Windows.Forms.Button;
HelpBtn: System.Windows.Forms.Button;
OptionBtn: System.Windows.Forms.Button;
halfBtn: System.Windows.Forms.Button;
AlarmViewBtn: System.Windows.Forms.Button;
method InitializeComponent;
{$ENDREGION}
end;
implementation
{$REGION Windows Form Designer generated code}
method MainForm.InitializeComponent;
begin
var resources: System.ComponentModel.ComponentResourceManager := new System.ComponentModel.ComponentResourceManager(typeOf(MainForm));
self.HideBtn := new System.Windows.Forms.Button();
self.ShutdownBtn := new System.Windows.Forms.Button();
self.AlarmViewBtn := new System.Windows.Forms.Button();
self.ScanBtn := new System.Windows.Forms.Button();
self.halfBtn := new System.Windows.Forms.Button();
self.OptionBtn := new System.Windows.Forms.Button();
self.HelpBtn := new System.Windows.Forms.Button();
self.LoginBtn := new System.Windows.Forms.Button();
self.MagiKalBtn := new System.Windows.Forms.Button();
self.DataViewBtn := new System.Windows.Forms.Button();
self.SystemBtn := new System.Windows.Forms.Button();
self.LoggingBtn := new System.Windows.Forms.Button();
self.PIDBtn := new System.Windows.Forms.Button();
self.ControlBtn := new System.Windows.Forms.Button();
self.AlarmsBtn := new System.Windows.Forms.Button();
self.SignalBtn := new System.Windows.Forms.Button();
self.UnitBtn := new System.Windows.Forms.Button();
self.CommBtn := new System.Windows.Forms.Button();
self.button2 := new System.Windows.Forms.Button();
self.button4 := new System.Windows.Forms.Button();
self.button5 := new System.Windows.Forms.Button();
self.button1 := new System.Windows.Forms.Button();
self.listBox1 := new System.Windows.Forms.ListBox();
self.SuspendLayout();
//
// HideBtn
//
self.HideBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.HideBtn.Location := new System.Drawing.Point(97, 518);
self.HideBtn.Name := 'HideBtn';
self.HideBtn.Size := new System.Drawing.Size(52, 24);
self.HideBtn.TabIndex := 36;
self.HideBtn.Text := 'Hide';
self.HideBtn.UseVisualStyleBackColor := true;
//
// ShutdownBtn
//
self.ShutdownBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.ShutdownBtn.Location := new System.Drawing.Point(12, 518);
self.ShutdownBtn.Name := 'ShutdownBtn';
self.ShutdownBtn.Size := new System.Drawing.Size(79, 24);
self.ShutdownBtn.TabIndex := 35;
self.ShutdownBtn.Text := 'Shutdown';
self.ShutdownBtn.UseVisualStyleBackColor := true;
self.ShutdownBtn.Click += new System.EventHandler(@self.ShutdownBtn_Click);
//
// AlarmViewBtn
//
self.AlarmViewBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.AlarmViewBtn.Location := new System.Drawing.Point(12, 449);
self.AlarmViewBtn.Name := 'AlarmViewBtn';
self.AlarmViewBtn.Size := new System.Drawing.Size(137, 24);
self.AlarmViewBtn.TabIndex := 34;
self.AlarmViewBtn.Text := 'Alarm Viewer';
self.AlarmViewBtn.UseVisualStyleBackColor := true;
//
// ScanBtn
//
self.ScanBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.ScanBtn.Location := new System.Drawing.Point(12, 488);
self.ScanBtn.Name := 'ScanBtn';
self.ScanBtn.Size := new System.Drawing.Size(137, 24);
self.ScanBtn.TabIndex := 33;
self.ScanBtn.Text := 'Start Scanning';
self.ScanBtn.UseVisualStyleBackColor := true;
//
// halfBtn
//
self.halfBtn.Location := new System.Drawing.Point(87, 233);
self.halfBtn.Name := 'halfBtn';
self.halfBtn.Size := new System.Drawing.Size(19, 23);
self.halfBtn.TabIndex := 32;
self.halfBtn.Text := '<';
self.halfBtn.UseVisualStyleBackColor := true;
//
// OptionBtn
//
self.OptionBtn.Location := new System.Drawing.Point(12, 233);
self.OptionBtn.Name := 'OptionBtn';
self.OptionBtn.Size := new System.Drawing.Size(62, 23);
self.OptionBtn.TabIndex := 31;
self.OptionBtn.Text := 'Option';
self.OptionBtn.UseVisualStyleBackColor := true;
//
// HelpBtn
//
self.HelpBtn.Location := new System.Drawing.Point(120, 233);
self.HelpBtn.Name := 'HelpBtn';
self.HelpBtn.Size := new System.Drawing.Size(19, 23);
self.HelpBtn.TabIndex := 30;
self.HelpBtn.Text := '?';
self.HelpBtn.UseVisualStyleBackColor := true;
//
// LoginBtn
//
self.LoginBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.LoginBtn.Location := new System.Drawing.Point(12, 204);
self.LoginBtn.Name := 'LoginBtn';
self.LoginBtn.Size := new System.Drawing.Size(137, 24);
self.LoginBtn.TabIndex := 29;
self.LoginBtn.Text := 'Login';
self.LoginBtn.UseVisualStyleBackColor := true;
self.LoginBtn.Click += new System.EventHandler(@self.LoginBtn_Click);
//
// MagiKalBtn
//
self.MagiKalBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.MagiKalBtn.Location := new System.Drawing.Point(12, 389);
self.MagiKalBtn.Name := 'MagiKalBtn';
self.MagiKalBtn.Size := new System.Drawing.Size(137, 24);
self.MagiKalBtn.TabIndex := 28;
self.MagiKalBtn.Text := 'MagiKal';
self.MagiKalBtn.UseVisualStyleBackColor := true;
//
// DataViewBtn
//
self.DataViewBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.DataViewBtn.Location := new System.Drawing.Point(12, 419);
self.DataViewBtn.Name := 'DataViewBtn';
self.DataViewBtn.Size := new System.Drawing.Size(137, 24);
self.DataViewBtn.TabIndex := 27;
self.DataViewBtn.Text := 'Data Viewer';
self.DataViewBtn.UseVisualStyleBackColor := true;
//
// SystemBtn
//
self.SystemBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.SystemBtn.Location := new System.Drawing.Point(80, 349);
self.SystemBtn.Name := 'SystemBtn';
self.SystemBtn.Size := new System.Drawing.Size(69, 24);
self.SystemBtn.TabIndex := 26;
self.SystemBtn.Text := 'System';
self.SystemBtn.UseVisualStyleBackColor := true;
//
// LoggingBtn
//
self.LoggingBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.LoggingBtn.Location := new System.Drawing.Point(80, 320);
self.LoggingBtn.Name := 'LoggingBtn';
self.LoggingBtn.Size := new System.Drawing.Size(69, 24);
self.LoggingBtn.TabIndex := 24;
self.LoggingBtn.Text := 'Logging';
self.LoggingBtn.UseVisualStyleBackColor := true;
//
// PIDBtn
//
self.PIDBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.PIDBtn.Location := new System.Drawing.Point(12, 320);
self.PIDBtn.Name := 'PIDBtn';
self.PIDBtn.Size := new System.Drawing.Size(69, 23);
self.PIDBtn.TabIndex := 23;
self.PIDBtn.Text := 'PID';
self.PIDBtn.UseVisualStyleBackColor := true;
//
// ControlBtn
//
self.ControlBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.ControlBtn.Location := new System.Drawing.Point(12, 291);
self.ControlBtn.Name := 'ControlBtn';
self.ControlBtn.Size := new System.Drawing.Size(70, 24);
self.ControlBtn.TabIndex := 22;
self.ControlBtn.Text := 'Control';
self.ControlBtn.UseVisualStyleBackColor := true;
//
// AlarmsBtn
//
self.AlarmsBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.AlarmsBtn.Location := new System.Drawing.Point(80, 291);
self.AlarmsBtn.Name := 'AlarmsBtn';
self.AlarmsBtn.Size := new System.Drawing.Size(69, 24);
self.AlarmsBtn.TabIndex := 21;
self.AlarmsBtn.Text := 'Alarms';
self.AlarmsBtn.UseVisualStyleBackColor := true;
//
// SignalBtn
//
self.SignalBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.SignalBtn.Location := new System.Drawing.Point(80, 262);
self.SignalBtn.Name := 'SignalBtn';
self.SignalBtn.Size := new System.Drawing.Size(69, 24);
self.SignalBtn.TabIndex := 20;
self.SignalBtn.Text := 'Signals';
self.SignalBtn.UseVisualStyleBackColor := true;
self.SignalBtn.Click += new System.EventHandler(@self.SignalBtn_Click);
//
// UnitBtn
//
self.UnitBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.UnitBtn.Location := new System.Drawing.Point(12, 262);
self.UnitBtn.Name := 'UnitBtn';
self.UnitBtn.Size := new System.Drawing.Size(69, 24);
self.UnitBtn.TabIndex := 19;
self.UnitBtn.Text := 'Units';
self.UnitBtn.UseVisualStyleBackColor := true;
self.UnitBtn.Click += new System.EventHandler(@self.UnitBtn_Click);
//
// CommBtn
//
self.CommBtn.Font := new System.Drawing.Font('Arial', 9.75, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, (0 as System.Byte));
self.CommBtn.Location := new System.Drawing.Point(12, 349);
self.CommBtn.Name := 'CommBtn';
self.CommBtn.Size := new System.Drawing.Size(69, 24);
self.CommBtn.TabIndex := 25;
self.CommBtn.Text := 'Comm';
self.CommBtn.UseVisualStyleBackColor := true;
self.CommBtn.Click += new System.EventHandler(@self.CommBtn_Click);
//
// button2
//
self.button2.Location := new System.Drawing.Point(37, 162);
self.button2.Name := 'button2';
self.button2.Size := new System.Drawing.Size(19, 23);
self.button2.TabIndex := 38;
self.button2.Text := 'button2';
self.button2.UseVisualStyleBackColor := true;
self.button2.Click += new System.EventHandler(@self.button2_Click);
//
// button4
//
self.button4.Location := new System.Drawing.Point(62, 162);
self.button4.Name := 'button4';
self.button4.Size := new System.Drawing.Size(19, 23);
self.button4.TabIndex := 39;
self.button4.Text := 'button4';
self.button4.UseVisualStyleBackColor := true;
self.button4.Click += new System.EventHandler(@self.button4_Click);
//
// button5
//
self.button5.Location := new System.Drawing.Point(87, 162);
self.button5.Name := 'button5';
self.button5.Size := new System.Drawing.Size(19, 23);
self.button5.TabIndex := 40;
self.button5.Text := 'button5';
self.button5.UseVisualStyleBackColor := true;
self.button5.Click += new System.EventHandler(@self.button5_Click);
//
// button1
//
self.button1.Location := new System.Drawing.Point(12, 162);
self.button1.Name := 'button1';
self.button1.Size := new System.Drawing.Size(19, 23);
self.button1.TabIndex := 41;
self.button1.Text := 'button1';
self.button1.UseVisualStyleBackColor := true;
self.button1.Click += new System.EventHandler(@self.button1_Click);
//
// listBox1
//
self.listBox1.Anchor := (((System.Windows.Forms.AnchorStyles.Top or System.Windows.Forms.AnchorStyles.Left)
or System.Windows.Forms.AnchorStyles.Right) as System.Windows.Forms.AnchorStyles);
self.listBox1.FormattingEnabled := true;
self.listBox1.Location := new System.Drawing.Point(10, 12);
self.listBox1.Name := 'listBox1';
self.listBox1.Size := new System.Drawing.Size(136, 95);
self.listBox1.TabIndex := 42;
//
// MainForm
//
self.ClientSize := new System.Drawing.Size(158, 554);
self.Controls.Add(self.listBox1);
self.Controls.Add(self.button1);
self.Controls.Add(self.button5);
self.Controls.Add(self.button4);
self.Controls.Add(self.button2);
self.Controls.Add(self.HideBtn);
self.Controls.Add(self.ShutdownBtn);
self.Controls.Add(self.AlarmViewBtn);
self.Controls.Add(self.ScanBtn);
self.Controls.Add(self.halfBtn);
self.Controls.Add(self.OptionBtn);
self.Controls.Add(self.HelpBtn);
self.Controls.Add(self.LoginBtn);
self.Controls.Add(self.MagiKalBtn);
self.Controls.Add(self.DataViewBtn);
self.Controls.Add(self.SystemBtn);
self.Controls.Add(self.CommBtn);
self.Controls.Add(self.LoggingBtn);
self.Controls.Add(self.PIDBtn);
self.Controls.Add(self.ControlBtn);
self.Controls.Add(self.AlarmsBtn);
self.Controls.Add(self.SignalBtn);
self.Controls.Add(self.UnitBtn);
self.DoubleBuffered := true;
self.Icon := (resources.GetObject('$this.Icon') as System.Drawing.Icon);
self.MaximizeBox := false;
self.MinimizeBox := false;
self.Name := 'MainForm';
self.Text := 'Millennia-FT';
self.Load += new System.EventHandler(@self.MainForm_Load);
self.ResumeLayout(false);
end;
{$ENDREGION}
end.
这是Main.pas表单代码:
namespace MillenniaMono.Main;
interface
uses
System.Drawing,
System.Collections,
System.Collections.Generic,
System.Windows.Forms,
System.ComponentModel,
System.Threading,
System.IO.Ports,
MillenniaMono.*;
type
/// <summary>
/// Summary description for MainForm.
/// </summary>
MainForm = partial class(System.Windows.Forms.Form)
private
method SignalBtn_Click(sender: System.Object; e: System.EventArgs);
method CommBtn_Click(sender: System.Object; e: System.EventArgs);
method button1_Click(sender: System.Object; e: System.EventArgs);
method button2_Click(sender: System.Object; e: System.EventArgs);
method button4_Click(sender: System.Object; e: System.EventArgs);
method button5_Click(sender: System.Object; e: System.EventArgs);
method MainForm_Load(sender: System.Object; e: System.EventArgs);
method ShutdownBtn_Click(sender: System.Object; e: System.EventArgs);
method MySerialData(sender: System.Object; e:SerialDataReceivedEventArgs);
method LoginBtn_Click(sender: System.Object; e: System.EventArgs);
method UnitBtn_Click(sender: System.Object; e: System.EventArgs);
protected
method Dispose(disposing: Boolean); override;
public
RX:Array[0..5] of byte;
TX:Array[0..6] of byte;
serialPort1:System.IO.Ports.SerialPort;
thr:Thread;
stoploop:Boolean;
mcommand:Byte;
thechannel:Integer;
fr : UnitForm;
constructor;
method FillTable;
method mythread;
end;
implementation
{$REGION Construction and Disposition}
constructor MainForm;
begin
//
// Required for Windows Form Designer support
//
InitializeComponent();
mcommand:=$AA;
thechannel:=$01;
stoploop:=false;
thr:=nil;
fr := new UnitForm;
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
method MainForm.Dispose(disposing: Boolean);
begin
if disposing then begin
//if assigned(components) then
// components.Dispose();
//
// TODO: Add custom disposition code here
//
if not(SerialPort1=nil) then
SerialPort1.Close;
stoploop:=true;
if not(thr=nil) then
thr.Abort;
end;
inherited Dispose(disposing);
end;
{$ENDREGION}
method MainForm.FillTable;
begin
end;
method MainForm.MySerialData(sender: Object; e: SerialDataReceivedEventArgs);
begin
if not SerialPort1.IsOpen then Exit;
try
SerialPort1.Read(RX,0,5);
fr.UpdateGrid(RX);
except on ex: exception do
begin
exit;
end;
end;
end;
procedure MainForm.mythread;
var x,y:Integer;
begin
while true do
begin
TX[0]:=$FF;
TX[1]:=$01;
TX[2]:=$01;
TX[3]:=thechannel;
TX[4]:=mcommand;
TX[5]:=(TX[2] xor TX[3] xor TX[4]);
SerialPort1.RtsEnable:=true;
SerialPort1.DiscardInBuffer;
SerialPort1.DiscardOutBuffer;
SerialPort1.Write(TX,0,6);
while SerialPort1.BytesToWrite>0 do;
y:=0;
for x:=0 to 700000 do
begin
y:=y+(x+10);
end;
SerialPort1.RtsEnable:=false;
Thread.Sleep(50);
if (stoploop) then
break;
end;
end;
method MainForm.SignalBtn_Click(sender: System.Object; e: System.EventArgs);
begin
end;
method MainForm.CommBtn_Click(sender: System.Object; e: System.EventArgs);
begin
if SerialPort1 = nil then
SerialPort1 := new System.Io.Ports.SerialPort();
SerialPort1.Close;
SerialPort1 := new System.Io.Ports.SerialPort();
SerialPort1.BaudRate:=19200;
SerialPort1.DataBits:=8;
SerialPort1.Parity:=System.IO.Ports.Parity.Even;
SerialPort1.PortName:='COM1';//'/dev/ttyS0';
SerialPort1.ReadBufferSize:=3000;
SerialPort1.ReadTimeout:=1000;
SerialPort1.StopBits:=System.IO.Ports.StopBits.One;
SerialPort1.WriteTimeout:=1000;
SerialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(@MySerialData);
SerialPort1.Open;
thr:= new Thread(@mythread);
thr.Start;
end;
method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);
begin
thechannel:=$04;
mcommand:=$A1;
end;
method MainForm.button2_Click(sender: System.Object; e: System.EventArgs);
begin
thechannel:=$04;
mcommand:=$A2;
end;
method MainForm.button4_Click(sender: System.Object; e: System.EventArgs);
begin
thechannel:=$04;
mcommand:=$A4;
end;
method MainForm.button5_Click(sender: System.Object; e: System.EventArgs);
begin
thechannel:=$04;
mcommand:=$A8;
end;
method MainForm.MainForm_Load(sender: System.Object; e: System.EventArgs);
begin
end;
method MainForm.ShutdownBtn_Click(sender: System.Object; e: System.EventArgs);
begin
stoploop:=true;
close;
end;
method MainForm.LoginBtn_Click(sender: System.Object; e: System.EventArgs);
begin
end;
method MainForm.UnitBtn_Click(sender: System.Object; e: System.EventArgs);
begin
fr.Show;
end;
end.
答案 0 :(得分:0)
我们现在正在对Prism的下一个版本进行最后的修改,我将尝试根据您的代码片段重现您的问题,明天是否仍然存在,如果是,我们可以修复它及时发布(即关闭)。如果这个片段没有完全复制,那么如果您可以将您的项目(或其相关部分)发送给我们,这可能会有所帮助,因此您可以使用您正在使用的确切代码进行测试,如果您想这样做,请请注意发送电子邮件至support@remobjects.com,引起我的注意。
在任何一种情况下,明天我都会告诉您是否可以使用我们最新的代码库重现该问题。
感谢名单, 渣
答案 1 :(得分:0)
我解决了。嗯,这真的是一种解决方法。由于编译器没有给我足够的信息来跟踪错误,我重新创建了具有所有相同设置的窗口表单并删除了另一个表单。现在它正在发挥作用。