Hi,
My code does somethink like this:
-
Load assembly from file
-
Create Type using CLID (mainType)
-
Activator.CreateInstance(mainType)
-
Now my code gets properties in this way : o.GetType().GetProperty("ActiveDocument", appDoc).GetValue(o, null); where o is object made by Activator and in appDoc is type from loaded assembly.
This all work fine, everytime I can get Type of object type variable. However now I need to make cast. I have type named Entity and type named ExternalReference. Relation between this types is illustrated below. How can I cast Entity variable to ExternalReference type Varible of type Entity is made by method call so I cannot suppress return type of method.
When I add assembly to references in VS2005 and I do something like
Entity variable = value;
ExternalReference ext = (ExternalReference)variable;
it works. For my situation (assembly is loaded when program is running) a try TypeConverter class to made a cast, but i throws exception that Entity cannot be cast to ExternalReference.
Hierarchy of types (rewrited from object browser)
ExternalReference
- Base Types
- IExternalReference
- IBlockReference
- IEntity
- IObject (this is not System.Object from .NET)
Thanks in advance...
Jind ich B ezina