R
Robb Sadler
I am trying to write several hardware interfaces that
would use the same base class and functions and be
implemented differently. I don't want to ship all of the
interfaces, but want to access them using the same generic
base class.
I have seen that I can use the Assembly.load method to
load the implementation I need for the hardware being
connected to, but wish to write the code such that I can
reference the methods of the class directly, and take
advantage of strong typing, etc. I don't see where using
dynamic loading of an assembly I can subsequently hook up
my strongly typed code to that assembly code.
Can I create this class from the loaded assembly and then
reference it using only the abstract class (eliminating
the requirement for the main compilation to know anything
about the derived class)?
The problem I am running into is how to allow the app to
switch between derived classes, without them all being
compiled in. Even the problem of instantiating them
correctly is befuddling me.
Here is an example:
namespace test
{
/// <summary>
/// base class for HW ctrl
/// </summary>
public class HWCtrl
{
public HWCtrl()
{
}
public virtual bool Run()
{
return true;
}
}
}
Now in a separate assembly:
namespace test
{
/// <summary>
/// derived class for HW ctrl
/// </summary>
public class DerivedHW : HWCtrl
{
public HWCtrl()
{
}
public bool Run()
{
return true;
}
}
}
I want to drop in the proper assembly for the job, and
bind to it at run time. Maybe this is easy, maybe it's not
possible, but I can't seem to find the answer in the
libraries or the web.
I have thought about using identical GUIDs for all the HW
implementations and creating a class interface, but that
seems to create its own problems.
Anyone been here before?
Thanks in advance,
Robb Sadler
would use the same base class and functions and be
implemented differently. I don't want to ship all of the
interfaces, but want to access them using the same generic
base class.
I have seen that I can use the Assembly.load method to
load the implementation I need for the hardware being
connected to, but wish to write the code such that I can
reference the methods of the class directly, and take
advantage of strong typing, etc. I don't see where using
dynamic loading of an assembly I can subsequently hook up
my strongly typed code to that assembly code.
Can I create this class from the loaded assembly and then
reference it using only the abstract class (eliminating
the requirement for the main compilation to know anything
about the derived class)?
The problem I am running into is how to allow the app to
switch between derived classes, without them all being
compiled in. Even the problem of instantiating them
correctly is befuddling me.
Here is an example:
namespace test
{
/// <summary>
/// base class for HW ctrl
/// </summary>
public class HWCtrl
{
public HWCtrl()
{
}
public virtual bool Run()
{
return true;
}
}
}
Now in a separate assembly:
namespace test
{
/// <summary>
/// derived class for HW ctrl
/// </summary>
public class DerivedHW : HWCtrl
{
public HWCtrl()
{
}
public bool Run()
{
return true;
}
}
}
I want to drop in the proper assembly for the job, and
bind to it at run time. Maybe this is easy, maybe it's not
possible, but I can't seem to find the answer in the
libraries or the web.
I have thought about using identical GUIDs for all the HW
implementations and creating a class interface, but that
seems to create its own problems.
Anyone been here before?
Thanks in advance,
Robb Sadler