我刚刚开发了一个非常简单的ActiveX控件(使用VS.NET向导,甚至不更改一行),并编译它。运行“regsvr32 ax1.ocx”后,我创建了一个新的C#WinFrom项目并将ActiveX控件拖到表单中。然后我构建并运行它,错误说:
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
内线:
((System.ComponentModel.ISupportInitialize)(this.axax11)).EndInit();
整个功能是:
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.axax11 = new Axax1Lib.Axax1();
((System.ComponentModel.ISupportInitialize)(this.axax11)).BeginInit();
this.SuspendLayout();
//
// axax11
//
this.axax11.Enabled = true;
this.axax11.Location = new System.Drawing.Point(103, 90);
this.axax11.Name = "axax11";
this.axax11.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axax11.OcxState")));
this.axax11.Size = new System.Drawing.Size(100, 50);
this.axax11.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.axax11);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.axax11)).EndInit();
this.ResumeLayout(false);
}
答案 0 :(得分:13)
我假设您在非托管C ++代码中编写了ActiveX控件。您需要创建此控件的64位版本,或者需要强制使用它的.NET程序以32位模式运行。后者是更快的修复,Project + Properties,Build选项卡,Platform Target = x86。