When dealing with COM, you should always work with the interface
definitions, and cast to that. COM is an interface-based framework, and it
only makes sense to work with interfaces.
When you see class types that represent COM objects, they really don't
honor the way that COM works, as it is an amalgam of all the interfaces that
the type implements. This is close to how VB works, and to be quite honest,
I don't recommend it.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have the following method to help me in installing some COM
> components onto the machine...below is a snippet that is causing the
> problem...
>
> Type objType = null;
> COMAdminCatalog objCatalog = null;
> COMAdminCatalogCollection objApplicationsColl = null;
> COMAdminCatalogObject objApp = null;
> try
> {
> objType =
> Type.GetTypeFromProgID("COMAdmin.COMAdminCatalog");
> objCatalog =
> (COMAdminCatalog)(System.Activator.CreateInstance(objType));
>
> It is part of setup application...so when I run the setup on my
> machine, it works fine....
>
> However, when I try to test it on one of our servers.....I get a
> Specified Cast is Invalid exception from this line objCatalog =
> (COMAdminCatalog)(System.Activator.CreateInstance(objType));
>
> I am guessing its a problem with either one of the last two
> line....forgive me, im new to COM
>
> Thanks in advance
>