G
Guest
I would like to dynamically load assemblies that implement a single
interface. I would like to reference a single definition of an interface
without creating and deploying a seperate assembly. How is this done in C#?
What constructs in C# provide the same functionality as #include C++?
For example:
Declared interface
interface MyAbstractInterface
A. Assembly 1
class DerivedClassOne : MyAbstractInterface
B. Assembly 2
class DerivedClassTwo : MyAbstractInterface
C. Application Executable, dynamically loading assemblies from above
MyAbstractInterface someVariable = null;
Assembly assemblyOne = System.AppDomain.CurrentDomain.Load(...);
MyAbstractInterface classOne =
(MyAbstractInterface)assembly.CreateInstance("DerivedClassOne");
// Use classOne
classOne.SomeMethod();
I've discovered that .NET is so strongly typed that defining the same
interface in each assembly causes an exception when I cast the object from
CreateInstance.
TIA,
SteveB, MCSD
Welch Allyn
interface. I would like to reference a single definition of an interface
without creating and deploying a seperate assembly. How is this done in C#?
What constructs in C# provide the same functionality as #include C++?
For example:
Declared interface
interface MyAbstractInterface
A. Assembly 1
class DerivedClassOne : MyAbstractInterface
B. Assembly 2
class DerivedClassTwo : MyAbstractInterface
C. Application Executable, dynamically loading assemblies from above
MyAbstractInterface someVariable = null;
Assembly assemblyOne = System.AppDomain.CurrentDomain.Load(...);
MyAbstractInterface classOne =
(MyAbstractInterface)assembly.CreateInstance("DerivedClassOne");
// Use classOne
classOne.SomeMethod();
I've discovered that .NET is so strongly typed that defining the same
interface in each assembly causes an exception when I cast the object from
CreateInstance.
TIA,
SteveB, MCSD
Welch Allyn