Automation server with events


I'm trying to develop a small automation dll server in C#.

Everything was fine until I got to events, which I was unable to do.

What I did, was something like :

File | New Project...
Selected "Class Library"
Some of the code was :

// Properties
public string SetEquipmentName
                        strEquipmentName = value;

// Methods
public void Initialize()
                        MessageBox.Show ("Initialize");
                  catch (Exception e)

// etc...

This is working fine with the clients, but I need to do throw events like :

void OnEquipmentConnect()
void OnEquipmentDisconnect (int ErrorCode, ref string ErrorText)


Please help me.

Thank you

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In your namespace, declare the delegates:

public delegate void OnEquipmentConnect();
public delegate void OnEquipmentDisconnect(int ErrorCode, string ErrorText);

in your class, declare the events:

public event OnEquipmentConnect Connect;
public event OnEquipmentDisconnect Disconnect;

and somewhere in your code, use:

public void Connect() // or some other method you have that does the connecting part
    if(this.Connect != null)

and do the same for the Disconnect Event.

This should work - you can now use something like:

Automation.Server server = new Automation.Server();
server.Connect += new OnEquipmentConnect(server_Connect);

private void server_Connect()
    // your code here

That's about I think.

jpcsAuthor Commented:
Hello Razzie,

I'm sorry but this didn't work.

I forgot to mention one thing that might be important...

The client application is writte in VB or Delphi or C++ Builder


jpcsAuthor Commented:

looks like I've found the answer to my question here :

Hope this helps someone!

Thanks for the help.

OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

I kinda misread the question, the author solved it, so I say PAQ / Refund.
jpcsAuthor Commented:
Thanks Razzie_

PAQed with points refunded (250)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.