Hi Experts! o/
I have written a DLL that interfaces an external machine, and has reason to return Event information sometimes. It has been posited that we add an Event to the DLL in order to get the Utility/Controller Application's "attention" when one of these Events occur - be it to display a warning, take automatic corrective action, or whatever. I thought it sounded like a good idea, and since I've used Events successfully in other Forms and Custom Controls - I figured it would be a no-brainer.
I was wrong. I can be big about it. But now I've got to figure out how to get Events working with this DLL.
For what it's worth, I've got the Event Handler declared at the top of the system, in with the variable declaration and definitions:
public event EventHandler MonitorStateChanged; // When an external force changes the [Monitor] interface value - tell everybody! (Or anybody who's listening...)
...and later on, down in the code where that particular interface value may change, I have the following code:
if (MonitorStateChanged != null)
...I'll figure out how to properly fill/utilize the [EventArgs] class later - we can send it an (Empty) for now.
And here's the problem: it doesn't work - it's not exposed in the client application as something with which I can connect. Seriously, I type the following:
sysComms.MonitorStateChanged += new EventHandler(monitorStatusChanged);
...and I get the following errors:
Error 1 Invalid token '+=' in class, struct, or interface member declaration
Error 2 Method must have a return type
Error 3 Identifier expected
Error 4 The type or namespace name 'MonitorStateChanged' does not exist in the namespace 'sysComms' (are you missing an assembly reference?)
Error 5 'sysTestSystem.mainForm.monitorStatusChanged(object, System.EventArgs)' is a 'method' but is used like a 'type'
...so it seems that - over in the sysComms64 DLL (from which [sysComms] is derived) it matters not that the event is defined [Public] and triggered internally.
I went back and checked a couple of my Controls, but they seem to work fine, no problem, and this is the exact same method I used there. Since this is a DLL (as opposed to a Control or Form), is there something else I need to include in "using..." or something? What have I missed?
Thanks for your time (and patience!)
- The Lurking LongFist