I have a dilemma.

I have a program that I was able to compile and run successfully when I first unzipped the files, but the buttons used to do frame acquisition were hidden off to the side.

After I started making changes (I did NOT actually modify the code in any way, just removed some references from the project that were not in use), a formerly functional line of code starts being the focal point for System.NullReferenceException.

public frmMain()
		{
			// Required for Windows Form Designer support
			InitializeComponent();

			splash.Show();
			splash.Refresh();
		
			serComm.SynchronizingObject = this;
			serComm.commEvent += new CommDelegate(DataIsHere);

			//input on RI is from the ECG
			serComm.RI_Event+= new RIChangeDelegate(ExternalTrigger1);
			//input on DSR is from the manual trigger button
			serComm.DSR_Event+=new DSRChangeDelegate(ExternalTrigger2);
			
			acquireTicker.Elapsed +=new ElapsedEventHandler(AcquisitionTick);
			acquireTicker.SynchronizingObject=this;
			
			acqTimeOut.Elapsed+=new ElapsedEventHandler(AcquisitionTimedOut);
            acqTimeOut.AutoReset=false;
			acqTimeOut.SynchronizingObject=this;
			
			startDelay.Elapsed+=new ElapsedEventHandler(StartUpDelay);
			startDelay.AutoReset=false;
			startDelay.SynchronizingObject=this;

			debounce.Interval=250;
			debounce.AutoReset=false;
			debounce.SynchronizingObject=this;

			birdPinger.Elapsed+= new ElapsedEventHandler(BirdPingerTick);
			birdPinger.Interval=100;
			birdPinger.AutoReset=false;
			birdPinger.SynchronizingObject=this;
           
			axLEAD1.DrawPersistence=true;
			
		}

The final line, axLEAD1, is what causes the exception.

axLEAD1 is declared in the frmMain class like so:

private AxLEADLib.AxLEAD axLEAD1;

Thinking that if I declare axLEAD1 as:

private AxLEADLib.AxLEAD axLEAD1=new AxLEADLib.AxLEAD();

Removes the Null reference exception, but I then get an 'InvalidActiveXStateException' occuring in the axinterop.leadlib.dll file.

I am really confused as to why this one line no longer works. Commenting it out 'Solves' everything, but makes the program useless, as there is no depiction of the video feed to work with.

Why is this happening, and what can I do about it?

Thanks in advance!

After I started making changes (I did NOT actually modify the code in any way, just removed some references from the project that were not in use)

One of the references you removed was in use by the axleadlib. Put them back and then get it running then remove them one at a time and test. the axleadlib has a dependency on something.

Actually, it wasn't.

Now, if I delete the project folder and extract the full project again, the same Null reference (or active X) exception occurs when I don't make any changes to the files.

then one of three things has happened.
Either it didnt work in the first place and you made a mistake in that it compiled but didnt run. Or you ran it on a different pc. Or you have made a change to something on your pc (such as an updated axlead dll).

It cant find that control. It is looking for one that may not be in the package you unzipped or you have a different version on your pc which isnt working with it.

You could try adding the control to your toolbox. Drag a new instance to your form which will update any references. Build it. Then delete it from your form (which leaves the correct references in your project still). Active x controls and .net can be flakey at times.

You are correct in that this was probably compiled on another system.
I am not aware of updated .dlls on this system, but the issue remains: I only get the active X stuff when I try to make the code work by making it axLead1 =new axleadlib.axlead();
This was not necessary previously. Should I be attempting to muck about with flakey activeX controls, or will I be unable to avoid it because I am correctly addressing the Null System Reference issue?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.