none
Creating plugins for a windows service - how to handle loaded classes with custom private functions? RRS feed

  • Question

  • I am creating a windows service to monitor the com ports of a computer for data from different types of machines.  The data will be outputted as a standardized xml formatted file.

    I am creating a plugin dll for each machine to monitor.  I created a Reader class that has functions like Start(), Stop(), Run(), Init(), etc...  Each dll's main class will inherit this class but it may have to add extra private functions or resources to handle converting the data.

    I have verything working except getting an instance of the class and executing the standard functions from it.

    I have an ArrayList of a worker class.  The worker class deals with threading and management.  One of the properties is an object called Reader which will contain the class from the loaded assembly.  How do I execute functions in that object?  The problem with using MethodInfo.Invoke is the functions need to be static.  Is there a way to to run non-static functions?

    • Edited by Kevin Jonas Monday, September 15, 2008 11:05 PM spelling
    Monday, September 15, 2008 10:20 PM

Answers

  • The term "constain" is pretty mysterious.  The first argument of MethodInfo.Invoke() is a reference to the object whose instance method you want to invoke.  Only if the method is static would you pass null for that argument.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, September 22, 2008 7:33 AM
    Monday, September 15, 2008 10:59 PM
    Moderator