hi,
i meet a problem when i try to develop an application with an ocx in
c#. the same ocx works well in vc,but not in c#,the Microsoft .NET common
language runtime throw a System.ExecutionEngineException error message.msdn
said it is a bug of .NET and advice make sure not have any indirect module
dependencies.i do not know what it means,but i do need this ocx
control.what should i do?
pls tell me , thanks in advance and sorry for my poor english..
(A)i use the Visual Studio .NET 2003;
(B)the pci-ocx control is an data acquisition one,here is AxPci9812,it is
come with the data acquisition card (ADLINK PCI9812)i bought;
(C)the ocx control works well in VC.net;
(D)the program does not interupt at my break point,but the data acquisition
is complete and it is right compare to the VC code result ,but it throw an
ExecutionEngineException error,then my program interrupt.
(E)my code sets as follow;
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using AxMULTIPLELib;
using MULTIPLELib;
//using System.Windows.Forms.AxHost.AxMULTIPLELib ;
namespace _9812test
{
/// <summary>
/// Form1 µÄժҪ˵Ã÷¡£
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private AxMULTIPLELib.AxPci9812 axPci98121;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
/// <summary>
/// ±ØÐèµÄÉè¼ÆÆ÷±äÁ¿¡£
/// </summary>
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows ´°ÌåÉè¼ÆÆ÷Ö§³ÖËù±ØÐèµÄ
//
InitializeComponent();
//
// TODO: ÔÚ InitializeComponent µ÷ÓúóÌí¼ÓÈκι¹Ô캯Êý´úÂë
//
}
/// <summary>
/// ÇåÀíËùÓÐÕýÔÚʹÓõÄ×ÊÔ´¡£
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows ´°ÌåÉè¼ÆÆ÷Éú³ÉµÄ´úÂë
/// <summary>
/// Éè¼ÆÆ÷Ö§³ÖËùÐèµÄ·½·¨ - ²»ÒªÊ¹ÓôúÂë±à¼*Æ÷ÐÞ¸Ä
/// ´Ë·½·¨µÄÄÚÈÝ¡£
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(Form1));
//this.axPci98121 = new AxMULTIPLELib.AxPci9812();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
//((System.ComponentModel.ISupportInitialize)(this.a xPci98121)).BeginInit();
this.SuspendLayout();
//
// axPci98121
//
this.axPci98121.Enabled = true;
this.axPci98121.Location = new System.Drawing.Point(56, 392);
this.axPci98121.Name = "axPci98121";
this.axPci98121.OcxState =
((System.Windows.Forms.AxHost.State)(resources.Get Object("axPci98121.OcxStat
e")));
this.axPci98121.Size = new System.Drawing.Size(32, 32);
this.axPci98121.TabIndex = 2;
this.axPci98121.Visible = false;
this.axPci98121.AiHalfReady += new
AxMULTIPLELib._DPci9812Events_AiHalfReadyEventHand ler(this.axPci98121_AiHalf
Ready);
this.axPci98121.AiComplete += new
AxMULTIPLELib._DPci9812Events_AiCompleteEventHandl er(this.axPci98121_AiCompl
ete);
//
// button1
//
this.button1.Location = new System.Drawing.Point(224, 408);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 16);
this.button1.TabIndex = 3;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(352, 392);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(112, 24);
this.label1.TabIndex = 5;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(536, 469);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
//this.Controls.Add(this.axPci98121);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.a xPci98121)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// Ó¦ÓóÌÐòµÄÖ÷Èë¿Úµã¡£
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
axPci98121.DeviceName="pci9812";
axPci98121.Open(0);
}
private void axPci98121_AiComplete(object sender,
AxMULTIPLELib._DPci9812Events_AiCompleteEvent e)
{
float[] scaledData=(float[])e.scaledData;
int k=scaledData.Length;
float[,] chandata=new float[4,(byte)(k/4)];
for(int i=0;i<(byte)(k/4);i++)
{
for(int j=0;j<3;j++)
{
chandata[i,j]=scaledData[4*i+j];
}
}
}
private void button1_Click(object sender, System.EventArgs e)
{
object filename=new object();
bool b=axPci98121.StartContAI("d:\\t.dat");//filename);
}
private void axPci98121_AiHalfReady(object sender,
AxMULTIPLELib._DPci9812Events_AiHalfReadyEvent e)
{
float[] scaledData=(float[])e.scaledData;
int k=scaledData.Length;
float[,] chandata=new float[4,(byte)(k/4)];
for(int i=0;i<(byte)(k/4);i++)
{
for(int j=0;j<3;j++)
{
chandata[i,j]=scaledData[4*i+j];
}
}
}
}
}